File tree Expand file tree Collapse file tree 4 files changed +107
-0
lines changed
src/lib/Persistence/Legacy/SharedGateway Expand file tree Collapse file tree 4 files changed +107
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,28 @@ public function getColumnNextIntegerValue(
2929 return null ;
3030 }
3131
32+ /**
33+ * Return a language sub select query for setName.
34+ *
35+ * The query generates the proper language mask at the runtime of the INSERT/UPDATE query
36+ * generated by setName.
37+ *
38+ * @see setName
39+ */
40+ public function getSetNameLanguageMaskSubQuery (): string
41+ {
42+ return <<<SQL
43+ (SELECT
44+ CASE
45+ WHEN (initial_language_id = :language_id AND (language_mask & :language_id) <> 0 )
46+ THEN (:language_id | 1)
47+ ELSE :language_id
48+ END
49+ FROM ezcontentobject
50+ WHERE id = :content_id)
51+ SQL ;
52+ }
53+
3254 public function getLastInsertedId (string $ sequenceName ): int
3355 {
3456 return (int )$ this ->connection ->lastInsertId ($ sequenceName );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @copyright Copyright (C) Ibexa AS. All rights reserved.
5+ * @license For full copyright and license information view LICENSE file distributed with this source code.
6+ */
7+ declare (strict_types=1 );
8+
9+ namespace Ibexa \Core \Persistence \Legacy \SharedGateway \DatabasePlatform ;
10+
11+ use Doctrine \DBAL \Connection ;
12+ use Ibexa \Core \Persistence \Legacy \SharedGateway \Gateway ;
13+
14+ final class PostgresqlGateway implements Gateway
15+ {
16+ /** @var \Doctrine\DBAL\Connection */
17+ private $ connection ;
18+
19+ public function __construct (Connection $ connection )
20+ {
21+ $ this ->connection = $ connection ;
22+ }
23+
24+ public function getColumnNextIntegerValue (
25+ string $ tableName ,
26+ string $ columnName ,
27+ string $ sequenceName
28+ ): ?int {
29+ return null ;
30+ }
31+
32+ public function getLastInsertedId (string $ sequenceName ): int
33+ {
34+ return (int )$ this ->connection ->lastInsertId ($ sequenceName );
35+ }
36+
37+ /**
38+ * Return a language sub select query for setName.
39+ *
40+ * The query generates the proper language mask at the runtime of the INSERT/UPDATE query
41+ * generated by setName.
42+ *
43+ * @see setName
44+ */
45+ public function getSetNameLanguageMaskSubQuery (): string
46+ {
47+ return <<<SQL
48+ (SELECT
49+ CASE
50+ WHEN (initial_language_id = :language_id AND (language_mask & :language_id) <> 0 )
51+ THEN (cast(:language_id as BIGINT) | 1)
52+ ELSE :language_id
53+ END
54+ FROM ezcontentobject
55+ WHERE id = :content_id)
56+ SQL ;
57+ }
58+ }
Original file line number Diff line number Diff line change @@ -49,6 +49,28 @@ public function getLastInsertedId(string $sequenceName): int
4949
5050 return $ this ->lastInsertedIds [$ sequenceName ];
5151 }
52+
53+ /**
54+ * Return a language sub select query for setName.
55+ *
56+ * The query generates the proper language mask at the runtime of the INSERT/UPDATE query
57+ * generated by setName.
58+ *
59+ * @see setName
60+ */
61+ public function getSetNameLanguageMaskSubQuery (): string
62+ {
63+ return <<<SQL
64+ (SELECT
65+ CASE
66+ WHEN (initial_language_id = :language_id AND (language_mask & :language_id) <> 0 )
67+ THEN (:language_id | 1)
68+ ELSE :language_id
69+ END
70+ FROM ezcontentobject
71+ WHERE id = :content_id)
72+ SQL ;
73+ }
5274}
5375
5476class_alias (SqliteGateway::class, 'eZ\Publish\Core\Persistence\Legacy\SharedGateway\DatabasePlatform\SqliteGateway ' );
Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ public function getColumnNextIntegerValue(
4141 * It returns integer as all the IDs in the Ibexa Legacy Storage are (big)integers
4242 */
4343 public function getLastInsertedId (string $ sequenceName ): int ;
44+
45+ /**
46+ * Return a language sub select query for setName.
47+ */
48+ public function getSetNameLanguageMaskSubQuery (): string ;
4449}
4550
4651class_alias (Gateway::class, 'eZ\Publish\Core\Persistence\Legacy\SharedGateway\Gateway ' );
You can’t perform that action at this time.
0 commit comments