| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * File containing the DoctrineDatabase Content Gateway class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright Copyright (C) eZ Systems AS. All rights reserved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license For full copyright and license information view LICENSE file distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace eZ\Publish\Core\Persistence\Legacy\Content\Gateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Doctrine\DBAL\Connection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use eZ\Publish\Core\Persistence\Legacy\Content\Gateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use eZ\Publish\Core\Persistence\Database\DatabaseHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use eZ\Publish\Core\Persistence\Database\UpdateQuery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use eZ\Publish\Core\Persistence\Database\InsertQuery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use eZ\Publish\Core\Persistence\Database\SelectQuery; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator as LanguageMaskGenerator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use eZ\Publish\SPI\Persistence\Content; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use eZ\Publish\SPI\Persistence\Content\CreateStruct; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use eZ\Publish\SPI\Persistence\Content\UpdateStruct; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use eZ\Publish\SPI\Persistence\Content\ContentInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use eZ\Publish\SPI\Persistence\Content\VersionInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use eZ\Publish\SPI\Persistence\Content\Field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use eZ\Publish\SPI\Persistence\Content\Language\Handler as LanguageHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use eZ\Publish\Core\Base\Exceptions\NotFoundException as NotFound; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use eZ\Publish\API\Repository\Values\Content\VersionInfo as APIVersionInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use DOMXPath; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use DOMDocument; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use PDO; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  * Doctrine database based content gateway. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | class DoctrineDatabase extends Gateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * eZ Doctrine database handler. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @var \eZ\Publish\Core\Persistence\Database\DatabaseHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     protected $dbHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * The native Doctrine connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      * Meant to be used to transition from eZ/Zeta interface to Doctrine. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      * @var \Doctrine\DBAL\Connection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     protected $connection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * Query builder. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @var \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     protected $queryBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * Caching language handler. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     protected $languageHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * Language mask generator. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     protected $languageMaskGenerator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * Creates a new gateway based on $db. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * @param \eZ\Publish\Core\Persistence\Database\DatabaseHandler $db | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * @param \Doctrine\DBAL\Connection $connection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * @param \eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder $queryBuilder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\Language\Handler $languageHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @param \eZ\Publish\Core\Persistence\Legacy\Content\Language\MaskGenerator $languageMaskGenerator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         DatabaseHandler $db, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         Connection $connection, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         QueryBuilder $queryBuilder, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         LanguageHandler $languageHandler, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         LanguageMaskGenerator $languageMaskGenerator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->dbHandler = $db; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $this->connection = $connection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $this->queryBuilder = $queryBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $this->languageHandler = $languageHandler; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $this->languageMaskGenerator = $languageMaskGenerator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * Get context definition for external storage layers. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     public function getContext() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             'identifier' => 'LegacyStorage', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |             'connection' => $this->dbHandler, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * Inserts a new content object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\CreateStruct $struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * @param mixed $currentVersionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * @return int ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |     public function insertContentObject(CreateStruct $struct, $currentVersionNo = 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $initialLanguageCode = $this->languageHandler->load($struct->initialLanguageId)->languageCode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         if (isset($struct->name[$initialLanguageCode])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |             $name = $struct->name[$initialLanguageCode]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             $name = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         $q = $this->dbHandler->createInsertQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         $q->insertInto( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             $this->dbHandler->quoteTable('ezcontentobject') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             $this->dbHandler->getAutoIncrementValue('ezcontentobject', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             $this->dbHandler->quoteColumn('current_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             $q->bindValue($currentVersionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             $this->dbHandler->quoteColumn('name'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             $q->bindValue($name, null, \PDO::PARAM_STR) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             $this->dbHandler->quoteColumn('contentclass_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             $q->bindValue($struct->typeId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             $this->dbHandler->quoteColumn('section_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             $q->bindValue($struct->sectionId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             $this->dbHandler->quoteColumn('owner_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |             $q->bindValue($struct->ownerId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             $this->dbHandler->quoteColumn('initial_language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             $q->bindValue($struct->initialLanguageId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             $this->dbHandler->quoteColumn('remote_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             $q->bindValue($struct->remoteId, null, \PDO::PARAM_STR) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             $this->dbHandler->quoteColumn('modified'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             $q->bindValue(0, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |             $this->dbHandler->quoteColumn('published'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             $q->bindValue(0, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |             $this->dbHandler->quoteColumn('status'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             $q->bindValue(ContentInfo::STATUS_DRAFT, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             $this->dbHandler->quoteColumn('language_mask'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             $q->bindValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |                 $this->generateLanguageMask( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |                     $struct->fields, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |                     $this->languageHandler->load($struct->initialLanguageId)->languageCode, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |                     $struct->alwaysAvailable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |                 \PDO::PARAM_INT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         return $this->dbHandler->lastInsertId( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             $this->dbHandler->getSequenceName('ezcontentobject', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      * Generates a language mask for $version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\Field[] $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * @param string $initialLanguageCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * @param bool $alwaysAvailable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     protected function generateLanguageMask(array $fields, $initialLanguageCode, $alwaysAvailable) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         $languages = array($initialLanguageCode => true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         foreach ($fields as $field) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             if (isset($languages[$field->languageCode])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |             $languages[$field->languageCode] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |         if ($alwaysAvailable) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             $languages['always-available'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         return $this->languageMaskGenerator->generateLanguageMask($languages); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * Inserts a new version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\Field[] $fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      * @return int ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |     public function insertVersion(VersionInfo $versionInfo, array $fields) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         /** @var $q \eZ\Publish\Core\Persistence\Database\InsertQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $q = $this->dbHandler->createInsertQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         $q->insertInto( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             $this->dbHandler->getAutoIncrementValue('ezcontentobject_version', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             $q->bindValue($versionInfo->versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |             $this->dbHandler->quoteColumn('modified'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             $q->bindValue($versionInfo->modificationDate, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             $this->dbHandler->quoteColumn('creator_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |             $q->bindValue($versionInfo->creatorId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             $this->dbHandler->quoteColumn('created'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             $q->bindValue($versionInfo->creationDate, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             $this->dbHandler->quoteColumn('status'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             $q->bindValue($versionInfo->status, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |             $this->dbHandler->quoteColumn('initial_language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             $q->bindValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |                 $this->languageHandler->loadByLanguageCode($versionInfo->initialLanguageCode)->id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |                 \PDO::PARAM_INT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |             $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             $q->bindValue($versionInfo->contentInfo->id, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             // As described in field mapping document | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |             $this->dbHandler->quoteColumn('workflow_event_pos'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |             $q->bindValue(0, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             $this->dbHandler->quoteColumn('language_mask'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             $q->bindValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |                 $this->generateLanguageMask( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |                     $fields, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |                     $versionInfo->initialLanguageCode, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |                     $versionInfo->contentInfo->alwaysAvailable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |                 \PDO::PARAM_INT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |         return $this->dbHandler->lastInsertId( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             $this->dbHandler->getSequenceName('ezcontentobject_version', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |      * Updates an existing content identified by $contentId in respect to $struct. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct $struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\VersionInfo $prePublishVersionInfo Provided on publish | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |     public function updateContent($contentId, MetadataUpdateStruct $struct, VersionInfo $prePublishVersionInfo = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |         $q->update($this->dbHandler->quoteTable('ezcontentobject')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         if (isset($struct->name)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |             $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                 $this->dbHandler->quoteColumn('name'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |                 $q->bindValue($struct->name, null, \PDO::PARAM_STR) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |         if (isset($struct->mainLanguageId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |                 $this->dbHandler->quoteColumn('initial_language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |                 $q->bindValue($struct->mainLanguageId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |         if (isset($struct->modificationDate)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |             $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |                 $this->dbHandler->quoteColumn('modified'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |                 $q->bindValue($struct->modificationDate, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |         if (isset($struct->ownerId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |             $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |                 $this->dbHandler->quoteColumn('owner_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |                 $q->bindValue($struct->ownerId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |         if (isset($struct->publicationDate)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |             $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |                 $this->dbHandler->quoteColumn('published'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |                 $q->bindValue($struct->publicationDate, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |         if (isset($struct->remoteId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |             $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |                 $this->dbHandler->quoteColumn('remote_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |                 $q->bindValue($struct->remoteId, null, \PDO::PARAM_STR) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         if ($prePublishVersionInfo !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |             $mask = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |             if (isset($struct->alwaysAvailable)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |                 $mask |= $struct->alwaysAvailable ? 1 : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |                 $mask |= $prePublishVersionInfo->contentInfo->alwaysAvailable ? 1 : 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |             foreach ($prePublishVersionInfo->languageIds as $languageId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |                 $mask |= $languageId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |             $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |                 $this->dbHandler->quoteColumn('language_mask'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |                 $q->bindValue($mask, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         $q->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |             $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |                 $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |                 $q->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |         // Handle alwaysAvailable flag update separately as it's a more complex task and has impact on several tables | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |         if (isset($struct->alwaysAvailable) || isset($struct->mainLanguageId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |             $this->updateAlwaysAvailableFlag($contentId, $struct->alwaysAvailable); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |      * Updates version $versionNo for content identified by $contentId, in respect to $struct. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |      * @param int $versionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\UpdateStruct $struct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |     public function updateVersion($contentId, $versionNo, UpdateStruct $struct) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |         $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $q->update( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             $this->dbHandler->quoteColumn('creator_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |             $q->bindValue($struct->creatorId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |             $this->dbHandler->quoteColumn('modified'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |             $q->bindValue($struct->modificationDate, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |             $this->dbHandler->quoteColumn('initial_language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |             $q->bindValue($struct->initialLanguageId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |             $this->dbHandler->quoteColumn('language_mask'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |             $q->expr->bitOr( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |                 $this->dbHandler->quoteColumn('language_mask'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |                 $q->bindValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |                     $this->generateLanguageMask( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |                         $struct->fields, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |                         $this->languageHandler->load($struct->initialLanguageId)->languageCode, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |                         false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |                     null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |                     \PDO::PARAM_INT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |             $q->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |                     $q->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |                     $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |                     $q->bindValue($versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |      * Updates "always available" flag for Content identified by $contentId, in respect to | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |      * Content's current main language and optionally new $alwaysAvailable state. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |      * @param bool|null $alwaysAvailable New "always available" value or null if not defined | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |     public function updateAlwaysAvailableFlag($contentId, $alwaysAvailable = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |         // We will need to know some info on the current language mask to update the flag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |         // everywhere needed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |         $contentInfoRow = $this->loadContentInfo($contentId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |         if (!isset($alwaysAvailable)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |             $alwaysAvailable = (bool)$contentInfoRow['language_mask'] & 1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |         /** @var $q \eZ\Publish\Core\Persistence\Database\UpdateQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |         $q | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |             ->update($this->dbHandler->quoteTable('ezcontentobject')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |             ->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |                 $this->dbHandler->quoteColumn('language_mask'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |                 $alwaysAvailable ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |                     $q->expr->bitOr($this->dbHandler->quoteColumn('language_mask'), 1) : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |                     $q->expr->bitAnd($this->dbHandler->quoteColumn('language_mask'), -2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |                     $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |                     $q->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |         // Now we need to update ezcontentobject_name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |         /** @var $qName \eZ\Publish\Core\Persistence\Database\UpdateQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |         $qName = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |         $qName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |             ->update($this->dbHandler->quoteTable('ezcontentobject_name')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |             ->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |                 $this->dbHandler->quoteColumn('language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |                 $alwaysAvailable ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |                     $qName->expr->bitOr($this->dbHandler->quoteColumn('language_id'), 1) : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |                     $qName->expr->bitAnd($this->dbHandler->quoteColumn('language_id'), -2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |                 $qName->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |                     $qName->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |                         $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |                         $qName->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |                     $qName->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |                         $this->dbHandler->quoteColumn('content_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |                         $qName->bindValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |                             $contentInfoRow['current_version'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |                             null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |                             \PDO::PARAM_INT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |                         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |         $qName->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |         // Now update ezcontentobject_attribute for current version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |         // Create update query that will be reused | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |         /** @var $qAttr \eZ\Publish\Core\Persistence\Database\UpdateQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |         $qAttr = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |         $qAttr | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |             ->update($this->dbHandler->quoteTable('ezcontentobject_attribute')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |                 $qAttr->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |                     $qAttr->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |                         $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |                         $qAttr->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |                     $qAttr->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |                         $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |                         $qAttr->bindValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |                             $contentInfoRow['current_version'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |                             null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |                             \PDO::PARAM_INT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |                         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |         // If there is only a single language, update all fields and return | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |         if (!$this->languageMaskGenerator->isLanguageMaskComposite($contentInfoRow['language_mask'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |             $qAttr->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |                 $this->dbHandler->quoteColumn('language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |                 $alwaysAvailable ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |                     $qAttr->expr->bitOr($this->dbHandler->quoteColumn('language_id'), 1) : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |                     $qAttr->expr->bitAnd($this->dbHandler->quoteColumn('language_id'), -2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |             $qAttr->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |         // Otherwise: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |         // 1. Remove always available flag on all fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |         $qAttr->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |             $this->dbHandler->quoteColumn('language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |             $qAttr->expr->bitAnd($this->dbHandler->quoteColumn('language_id'), -2) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         $qAttr->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         // 2. If Content is always available set the flag only on fields in main language | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |         if ($alwaysAvailable) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |             $qAttr->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |                 $this->dbHandler->quoteColumn('language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |                 $qAttr->expr->bitOr($this->dbHandler->quoteColumn('language_id'), 1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |             $qAttr->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |                 $qAttr->expr->gt( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |                     $qAttr->expr->bitAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |                         $this->dbHandler->quoteColumn('language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |                         $qAttr->bindValue($contentInfoRow['initial_language_id'], null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |                     $qAttr->bindValue(0, null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |             $qAttr->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |      * Sets the status of the version identified by $contentId and $version to $status. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |      * The $status can be one of STATUS_DRAFT, STATUS_PUBLISHED, STATUS_ARCHIVED | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |      * @param int $version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |      * @param int $status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |     public function setStatus($contentId, $version, $status) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |         $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         $q->update( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |             $this->dbHandler->quoteColumn('status'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |             $q->bindValue($status, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |             $this->dbHandler->quoteColumn('modified'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |             $q->bindValue(time(), null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |             $q->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |                     $q->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |                     $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |                     $q->bindValue($version, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |         $statement = $q->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |         if ((bool)$statement->rowCount() === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |         if ($status !== APIVersionInfo::STATUS_PUBLISHED) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |             return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |         // If the version's status is PUBLISHED, we set the content to published status as well | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |         $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |         $q->update( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |             $this->dbHandler->quoteTable('ezcontentobject') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |             $this->dbHandler->quoteColumn('status'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |             $q->bindValue(ContentInfo::STATUS_PUBLISHED, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |             $this->dbHandler->quoteColumn('current_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |             $q->bindValue($version, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |             $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |                 $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |                 $q->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |         $statement = $q->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |         return (bool)$statement->rowCount(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |      * Inserts a new field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |      * Only used when a new field is created (i.e. a new object or a field in a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |      * new language!). After that, field IDs need to stay the same, only the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |      * version number changes. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content $content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\Field $field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |      * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |      * @return int ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |     public function insertNewField(Content $content, Field $field, StorageFieldValue $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |         $q = $this->dbHandler->createInsertQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |         $this->setInsertFieldValues($q, $content, $field, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |         // Insert with auto increment ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |         $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |             $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |             $this->dbHandler->getAutoIncrementValue('ezcontentobject_attribute', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |         return $this->dbHandler->lastInsertId( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |             $this->dbHandler->getSequenceName('ezcontentobject_attribute', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |      * Inserts an existing field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |      * Used to insert a field with an exsting ID but a new version number. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |      * @param Content $content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |      * @param Field $field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |      * @param StorageFieldValue $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |     public function insertExistingField(Content $content, Field $field, StorageFieldValue $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |         $q = $this->dbHandler->createInsertQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |         $this->setInsertFieldValues($q, $content, $field, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |         $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |             $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |             $q->bindValue($field->id, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |      * Sets field (ezcontentobject_attribute) values to the given query. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |      * @param \eZ\Publish\Core\Persistence\Database\InsertQuery $q | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |      * @param Content $content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |      * @param Field $field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |      * @param StorageFieldValue $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |     protected function setInsertFieldValues(InsertQuery $q, Content $content, Field $field, StorageFieldValue $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |         $q->insertInto( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |             $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |             $q->bindValue($content->versionInfo->contentInfo->id, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |             $this->dbHandler->quoteColumn('contentclassattribute_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |             $q->bindValue($field->fieldDefinitionId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |             $this->dbHandler->quoteColumn('data_type_string'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |             $q->bindValue($field->type) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |             $this->dbHandler->quoteColumn('language_code'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |             $q->bindValue($field->languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |             $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |             $q->bindValue($field->versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |             $this->dbHandler->quoteColumn('data_float'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |             $q->bindValue($value->dataFloat) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |             $this->dbHandler->quoteColumn('data_int'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |             $q->bindValue($value->dataInt, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |             $this->dbHandler->quoteColumn('data_text'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |             $q->bindValue($value->dataText) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |             $this->dbHandler->quoteColumn('sort_key_int'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |             $q->bindValue($value->sortKeyInt, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |             $this->dbHandler->quoteColumn('sort_key_string'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |             $q->bindValue(mb_substr($value->sortKeyString, 0, 255)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |             $this->dbHandler->quoteColumn('language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |             $q->bindValue( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |                 $this->languageMaskGenerator->generateLanguageIndicator( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |                     $field->languageCode, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |                     $this->isLanguageAlwaysAvailable($content, $field->languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |                 null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |                 \PDO::PARAM_INT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |      * Checks if $languageCode is always available in $content. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content $content | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  |      * @param string $languageCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |     protected function isLanguageAlwaysAvailable(Content $content, $languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |         return ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |             $content->versionInfo->contentInfo->alwaysAvailable && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |             $content->versionInfo->contentInfo->mainLanguageCode === $languageCode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  |      * Updates an existing field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |      * @param Field $field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  |      * @param StorageFieldValue $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  |     public function updateField(Field $field, StorageFieldValue $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  |         // Note, no need to care for language_id here, since Content->$alwaysAvailable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  |         // cannot change on update | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  |         $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  |         $this->setFieldUpdateValues($q, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  |         $q->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  |             $q->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  |                     $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  |                     $q->bindValue($field->id, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  |                     $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  |                     $q->bindValue($field->versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  |      * Sets update fields for $value on $q. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  |      * @param \eZ\Publish\Core\Persistence\Database\UpdateQuery $q | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  |      * @param StorageFieldValue $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  |     protected function setFieldUpdateValues(UpdateQuery $q, StorageFieldValue $value) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  |         $q->update( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |             $this->dbHandler->quoteColumn('data_float'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |             $q->bindValue($value->dataFloat) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  |             $this->dbHandler->quoteColumn('data_int'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |             $q->bindValue($value->dataInt, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |             $this->dbHandler->quoteColumn('data_text'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |             $q->bindValue($value->dataText) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |             $this->dbHandler->quoteColumn('sort_key_int'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |             $q->bindValue($value->sortKeyInt, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |             $this->dbHandler->quoteColumn('sort_key_string'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |             $q->bindValue(mb_substr($value->sortKeyString, 0, 255)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |      * Updates an existing, non-translatable field. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\Field $field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |      * @param \eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldValue $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  |     public function updateNonTranslatableField( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |         Field $field, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  |         StorageFieldValue $value, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |         $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |         // Note, no need to care for language_id here, since Content->$alwaysAvailable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |         // cannot change on update | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |         $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |         $this->setFieldUpdateValues($q, $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |         $q->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |             $q->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |                     $this->dbHandler->quoteColumn('contentclassattribute_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |                     $q->bindValue($field->fieldDefinitionId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  |                     $q->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |                 $q->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |                     $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |                     $q->bindValue($field->versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |      * Loads data for a content object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |      * Returns an array with the relevant data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |      * @param mixed $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |      * @param mixed $version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |      * @param string[] $translations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |     public function load($contentId, $version, array $translations = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |         $query = $this->queryBuilder->createFindQuery($translations); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |         $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |             $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |                     $this->dbHandler->quoteColumn('id', 'ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |                     $query->bindValue($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |                     $this->dbHandler->quoteColumn('version', 'ezcontentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |                     $query->bindValue($version) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |         return $statement->fetchAll(\PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  |      * @see loadContentInfo(), loadContentInfoByRemoteId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |      * @param string $column | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |      * @param mixed $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |      * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |     private function internalLoadContentInfo($column, $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |         /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |         $query->select( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |             'ezcontentobject.*', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |             $this->dbHandler->aliasedColumn($query, 'main_node_id', 'ezcontentobject_tree') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |         )->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |             $this->dbHandler->quoteTable('ezcontentobject') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |         )->leftJoin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_tree'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  |             $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_tree'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |                     $this->dbHandler->quoteColumn('id', 'ezcontentobject') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |                     $this->dbHandler->quoteColumn('main_node_id', 'ezcontentobject_tree'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |                     $this->dbHandler->quoteColumn('node_id', 'ezcontentobject_tree') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |                 $this->dbHandler->quoteColumn($column, 'ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |                 $query->bindValue($id, null, $column === 'id' ? PDO::PARAM_INT : PDO::PARAM_STR) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |         $row = $statement->fetch(PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |         if (empty($row)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |             throw new NotFound('content', "$column: $id"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |         return $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  |      * Loads info for content identified by $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |      * Will basically return a hash containing all field values for ezcontentobject table plus some additional keys: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |      *  - always_available => Boolean indicating if content's language mask contains alwaysAvailable bit field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |      *  - main_language_code => Language code for main (initial) language. E.g. "eng-GB". | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |      * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |     public function loadContentInfo($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |         return $this->internalLoadContentInfo('id', $contentId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |      * Loads info for a content object identified by its remote ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |      * Returns an array with the relevant data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |      * @param mixed $remoteId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |      * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |      * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 924 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 925 |  |  |     public function loadContentInfoByRemoteId($remoteId) | 
            
                                                                        
                            
            
                                    
            
            
                | 926 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 927 |  |  |         return $this->internalLoadContentInfo('remote_id', $remoteId); | 
            
                                                                        
                            
            
                                    
            
            
                | 928 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |      * Loads version info for content identified by $contentId and $versionNo. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |      * Will basically return a hash containing all field values from ezcontentobject_version table plus following keys: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |      *  - names => Hash of content object names. Key is the language code, value is the name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  |      *  - languages => Hash of language ids. Key is the language code (e.g. "eng-GB"), value is the language numeric id without the always available bit. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  |      *  - initial_language_code => Language code for initial language in this version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |      * @param int $versionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 942 |  | View Code Duplication |     public function loadVersionInfo($contentId, $versionNo) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |         $query = $this->queryBuilder->createVersionInfoFindQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |         $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |             $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  |                     $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |                     $this->dbHandler->quoteColumn('version', 'ezcontentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  |                     $query->bindValue($versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |         return $statement->fetchAll(\PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  |      * Returns data for all versions with given status created by the given $userId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 966 |  |  |      * @param int $userId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 967 |  |  |      * @param int $status | 
            
                                                                                                            
                            
            
                                    
            
            
                | 968 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 969 |  |  |      * @return string[][] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 970 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 971 |  |  |     public function listVersionsForUser($userId, $status = VersionInfo::STATUS_DRAFT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 972 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 973 |  |  |         $query = $this->queryBuilder->createVersionInfoFindQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 974 |  |  |         $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 975 |  |  |             $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 976 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 977 |  |  |                     $this->dbHandler->quoteColumn('status', 'ezcontentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 978 |  |  |                     $query->bindValue($status, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 979 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 980 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 981 |  |  |                     $this->dbHandler->quoteColumn('creator_id', 'ezcontentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 982 |  |  |                     $query->bindValue($userId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 983 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 984 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 985 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 986 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 987 |  |  |         return $this->listVersionsHelper($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 988 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 989 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 990 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 991 |  |  |      * Returns all version data for the given $contentId, optionally filtered by status. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 992 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 993 |  |  |      * Result is returned with oldest version first (using version id as it has index and is auto increment). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 994 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 995 |  |  |      * @param mixed $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 996 |  |  |      * @param mixed|null $status Optional argument to filter versions by status, like {@see VersionInfo::STATUS_ARCHIVED}. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 997 |  |  |      * @param int $limit Limit for items returned, -1 means none. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 998 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 999 |  |  |      * @return string[][] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1000 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1001 |  |  |     public function listVersions($contentId, $status = null, $limit = -1) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1002 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1003 |  |  |         $query = $this->queryBuilder->createVersionInfoFindQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1004 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1005 |  |  |         $filter = $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1006 |  |  |             $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1007 |  |  |             $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1008 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1009 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1010 |  |  |         if ($status !== null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1011 |  |  |             $filter = $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1012 |  |  |                 $filter, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1013 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1014 |  |  |                     $this->dbHandler->quoteColumn('status', 'ezcontentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1015 |  |  |                     $query->bindValue($status, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1016 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1017 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1018 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1019 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1020 |  |  |         $query->where($filter); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1021 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1022 |  |  |         if ($limit > 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1023 |  |  |             $query->limit($limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1024 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1025 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1026 |  |  |         return $this->listVersionsHelper($query); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1027 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1028 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1029 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1030 |  |  |      * Helper for {@see listVersions()} and {@see listVersionsForUser()} that filters duplicates | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1031 |  |  |      * that are the result of the cartesian product performed by createVersionInfoFindQuery(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1032 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1033 |  |  |      * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1034 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1035 |  |  |      * @return string[][] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1036 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1037 |  |  |     private function listVersionsHelper(SelectQuery $query) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1038 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1039 |  |  |         $query->orderBy( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1040 |  |  |             $this->dbHandler->quoteColumn('id', 'ezcontentobject_version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1041 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1042 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1043 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1044 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1045 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1046 |  |  |         $results = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1047 |  |  |         $previousId = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1048 |  |  |         foreach ($statement->fetchAll(\PDO::FETCH_ASSOC) as $row) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1049 |  |  |             if ($row['ezcontentobject_version_id'] == $previousId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1050 |  |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1051 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1052 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1053 |  |  |             $previousId = $row['ezcontentobject_version_id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1054 |  |  |             $results[] = $row; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1055 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1056 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1057 |  |  |         return $results; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1058 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1059 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1060 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1061 |  |  |      * Returns all version numbers for the given $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1062 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1063 |  |  |      * @param mixed $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1064 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1065 |  |  |      * @return int[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1066 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1067 |  |  |     public function listVersionNumbers($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1068 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1069 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1070 |  |  |         $query->selectDistinct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1071 |  |  |             $this->dbHandler->quoteColumn('version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1072 |  |  |         )->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1073 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1074 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1075 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1076 |  |  |                 $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1077 |  |  |                 $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1078 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1079 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1080 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1081 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1082 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1083 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1084 |  |  |         return $statement->fetchAll(\PDO::FETCH_COLUMN); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1085 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1086 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1087 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1088 |  |  |      * Returns last version number for content identified by $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1089 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1090 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1091 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1092 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1093 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1094 |  |  |     public function getLastVersionNumber($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1095 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1096 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1097 |  |  |         $query->select( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1098 |  |  |             $query->expr->max($this->dbHandler->quoteColumn('version')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1099 |  |  |         )->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1100 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1101 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1102 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1103 |  |  |                 $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1104 |  |  |                 $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1105 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1106 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1107 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1108 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1109 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1110 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1111 |  |  |         return (int)$statement->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1112 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1114 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1115 |  |  |      * Returns all IDs for locations that refer to $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1116 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1117 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1118 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1119 |  |  |      * @return int[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1120 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1121 |  |  |     public function getAllLocationIds($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1122 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1123 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1124 |  |  |         $query->select( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1125 |  |  |             $this->dbHandler->quoteColumn('node_id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1126 |  |  |         )->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1127 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_tree') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1128 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1129 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1130 |  |  |                 $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1131 |  |  |                 $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1132 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1133 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1135 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1136 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1138 |  |  |         return $statement->fetchAll(\PDO::FETCH_COLUMN); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1139 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1141 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1142 |  |  |      * Returns all field IDs of $contentId grouped by their type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1143 |  |  |      * If $versionNo is set only field IDs for that version are returned. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1144 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1145 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1146 |  |  |      * @param int|null $versionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1147 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1148 |  |  |      * @return int[][] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1149 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1150 |  |  |     public function getFieldIdsByType($contentId, $versionNo = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1151 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1152 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1153 |  |  |         $query->select( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1154 |  |  |             $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1155 |  |  |             $this->dbHandler->quoteColumn('data_type_string') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1156 |  |  |         )->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1157 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1158 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1159 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1160 |  |  |                 $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1161 |  |  |                 $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1162 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1163 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1165 |  |  |         if (isset($versionNo)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1166 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1167 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1168 |  |  |                     $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1169 |  |  |                     $query->bindValue($versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1170 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1171 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1172 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1173 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1174 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1175 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1177 |  |  |         $result = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1178 |  |  |         foreach ($statement->fetchAll() as $row) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1179 |  |  |             if (!isset($result[$row['data_type_string']])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1180 |  |  |                 $result[$row['data_type_string']] = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1181 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1182 |  |  |             $result[$row['data_type_string']][] = (int)$row['id']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1183 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1184 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1185 |  |  |         return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1186 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1188 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1189 |  |  |      * Deletes relations to and from $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1190 |  |  |      * If $versionNo is set only relations for that version are deleted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1191 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1192 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1193 |  |  |      * @param int|null $versionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1194 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1195 |  |  |     public function deleteRelations($contentId, $versionNo = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1196 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1197 |  |  |         $query = $this->dbHandler->createDeleteQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1198 |  |  |         $query->deleteFrom( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1199 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1200 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1202 |  |  |         if (isset($versionNo)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1203 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1204 |  |  |                 $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1205 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1206 |  |  |                         $this->dbHandler->quoteColumn('from_contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1207 |  |  |                         $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1208 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1209 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1210 |  |  |                         $this->dbHandler->quoteColumn('from_contentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1211 |  |  |                         $query->bindValue($versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1212 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1213 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1214 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1215 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1216 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1217 |  |  |                 $query->expr->lOr( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1218 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1219 |  |  |                         $this->dbHandler->quoteColumn('from_contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1220 |  |  |                         $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1221 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1222 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1223 |  |  |                         $this->dbHandler->quoteColumn('to_contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1224 |  |  |                         $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1225 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1226 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1227 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1228 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1230 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1231 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1233 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1234 |  |  |      * Removes relations to Content with $contentId from Relation and RelationList field type fields. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1235 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1236 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1237 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1238 |  |  |     public function removeReverseFieldRelations($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1239 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1240 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1241 |  |  |         $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1242 |  |  |             ->select('ezcontentobject_attribute.*') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1243 |  |  |             ->from('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1244 |  |  |             ->innerJoin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1245 |  |  |                 'ezcontentobject_link', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1246 |  |  |                 $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1247 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1248 |  |  |                         $this->dbHandler->quoteColumn('from_contentobject_id', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1249 |  |  |                         $this->dbHandler->quoteColumn('contentobject_id', 'ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1250 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1251 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1252 |  |  |                         $this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1253 |  |  |                         $this->dbHandler->quoteColumn('version', 'ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1254 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1255 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1256 |  |  |                         $this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1257 |  |  |                         $this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1258 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1259 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1260 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1261 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1262 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1263 |  |  |                     $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1264 |  |  |                     $query->bindValue($contentId, null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1265 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1266 |  |  |                 $query->expr->gt( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1267 |  |  |                     $query->expr->bitAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1268 |  |  |                         $this->dbHandler->quoteColumn('relation_type', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1269 |  |  |                         $query->bindValue(8, null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1270 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1271 |  |  |                     0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1272 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1273 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1275 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1276 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1277 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1278 |  |  |         while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1279 |  |  |             if ($row['data_type_string'] === 'ezobjectrelation') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1280 |  |  |                 $this->removeRelationFromRelationField($row); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1281 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1283 |  |  |             if ($row['data_type_string'] === 'ezobjectrelationlist') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1284 |  |  |                 $this->removeRelationFromRelationListField($contentId, $row); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1285 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1286 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1287 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1288 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1289 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1290 |  |  |      * Updates field value of RelationList field type identified by given $row data, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1291 |  |  |      * removing relations toward given $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1292 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1293 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1294 |  |  |      * @param array $row | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1295 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1296 |  |  |     protected function removeRelationFromRelationListField($contentId, array $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1297 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1298 |  |  |         $document = new DOMDocument('1.0', 'utf-8'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1299 |  |  |         $document->loadXML($row['data_text']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1301 |  |  |         $xpath = new DOMXPath($document); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1302 |  |  |         $xpathExpression = "//related-objects/relation-list/relation-item[@contentobject-id='{$contentId}']"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1304 |  |  |         $relationItems = $xpath->query($xpathExpression); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1305 |  |  |         foreach ($relationItems as $relationItem) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1306 |  |  |             $relationItem->parentNode->removeChild($relationItem); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1307 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1309 |  |  |         $query = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1310 |  |  |         $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1311 |  |  |             ->update('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1312 |  |  |             ->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1313 |  |  |                 'data_text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1314 |  |  |                 $query->bindValue($document->saveXML(), null, PDO::PARAM_STR) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1315 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1316 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1317 |  |  |                 $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1318 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1319 |  |  |                         $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1320 |  |  |                         $query->bindValue($row['id'], null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1321 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1322 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1323 |  |  |                         $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1324 |  |  |                         $query->bindValue($row['version'], null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1325 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1326 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1327 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1328 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1329 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1330 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1331 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1332 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1333 |  |  |      * Updates field value of Relation field type identified by given $row data, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1334 |  |  |      * removing relation data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1335 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1336 |  |  |      * @param array $row | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1337 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1338 |  |  |     protected function removeRelationFromRelationField(array $row) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1339 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1340 |  |  |         $query = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1341 |  |  |         $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1342 |  |  |             ->update('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1343 |  |  |             ->set('data_int', $query->bindValue(null, null, PDO::PARAM_INT)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1344 |  |  |             ->set('sort_key_int', $query->bindValue(0, null, PDO::PARAM_INT)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1345 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1346 |  |  |                 $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1347 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1348 |  |  |                         $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1349 |  |  |                         $query->bindValue($row['id'], null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1350 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1351 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1352 |  |  |                         $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1353 |  |  |                         $query->bindValue($row['version'], null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1354 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1355 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1356 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1358 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1359 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1360 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1361 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1362 |  |  |      * Deletes the field with the given $fieldId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1363 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1364 |  |  |      * @param int $fieldId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1365 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1366 |  |  |     public function deleteField($fieldId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1367 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1368 |  |  |         $query = $this->dbHandler->createDeleteQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1369 |  |  |         $query->deleteFrom( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1370 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1371 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1372 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1373 |  |  |                 $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1374 |  |  |                 $query->bindValue($fieldId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1375 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1376 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1378 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1379 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1380 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1381 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1382 |  |  |      * Deletes all fields of $contentId in all versions. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1383 |  |  |      * If $versionNo is set only fields for that version are deleted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1384 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1385 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1386 |  |  |      * @param int|null $versionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1387 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1388 |  |  |     public function deleteFields($contentId, $versionNo = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1389 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1390 |  |  |         $query = $this->dbHandler->createDeleteQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1391 |  |  |         $query->deleteFrom('ezcontentobject_attribute') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1392 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1393 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1394 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1395 |  |  |                     $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1396 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1397 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1398 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1399 |  |  |         if (isset($versionNo)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1400 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1401 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1402 |  |  |                     $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1403 |  |  |                     $query->bindValue($versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1404 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1405 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1406 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1407 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1408 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1409 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1411 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1412 |  |  |      * Deletes all versions of $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1413 |  |  |      * If $versionNo is set only that version is deleted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1414 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1415 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1416 |  |  |      * @param int|null $versionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1417 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1418 |  |  |     public function deleteVersions($contentId, $versionNo = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1419 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1420 |  |  |         $query = $this->dbHandler->createDeleteQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1421 |  |  |         $query->deleteFrom('ezcontentobject_version') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1422 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1423 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1424 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1425 |  |  |                     $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1426 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1427 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1429 |  |  |         if (isset($versionNo)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1430 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1431 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1432 |  |  |                     $this->dbHandler->quoteColumn('version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1433 |  |  |                     $query->bindValue($versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1434 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1435 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1436 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1438 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1439 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1440 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1441 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1442 |  |  |      * Deletes all names of $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1443 |  |  |      * If $versionNo is set only names for that version are deleted. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1444 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1445 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1446 |  |  |      * @param int|null $versionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1447 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1448 |  |  |     public function deleteNames($contentId, $versionNo = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1449 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1450 |  |  |         $query = $this->dbHandler->createDeleteQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1451 |  |  |         $query->deleteFrom('ezcontentobject_name') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1452 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1453 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1454 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1455 |  |  |                     $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1456 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1457 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1458 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1459 |  |  |         if (isset($versionNo)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1460 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1461 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1462 |  |  |                     $this->dbHandler->quoteColumn('content_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1463 |  |  |                     $query->bindValue($versionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1464 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1465 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1466 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1467 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1468 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1469 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1470 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1471 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1472 |  |  |      * Sets the name for Content $contentId in version $version to $name in $language. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1473 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1474 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1475 |  |  |      * @param int $version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1476 |  |  |      * @param string $name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1477 |  |  |      * @param string $language | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1478 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1479 |  |  |     public function setName($contentId, $version, $name, $language) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1480 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1481 |  |  |         $language = $this->languageHandler->loadByLanguageCode($language); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1483 |  |  |         // Is it an insert or an update ? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1484 |  |  |         $qSelect = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1485 |  |  |         $qSelect | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1486 |  |  |             ->select( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1487 |  |  |                 $qSelect->alias($qSelect->expr->count('*'), 'count') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1488 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1489 |  |  |             ->from($this->dbHandler->quoteTable('ezcontentobject_name')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1490 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1491 |  |  |                 $qSelect->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1492 |  |  |                     $qSelect->expr->eq($this->dbHandler->quoteColumn('contentobject_id'), $qSelect->bindValue($contentId)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1493 |  |  |                     $qSelect->expr->eq($this->dbHandler->quoteColumn('content_version'), $qSelect->bindValue($version)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1494 |  |  |                     $qSelect->expr->eq($this->dbHandler->quoteColumn('content_translation'), $qSelect->bindValue($language->languageCode)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1495 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1496 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1497 |  |  |         $stmt = $qSelect->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1498 |  |  |         $stmt->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1499 |  |  |         $res = $stmt->fetchAll(\PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1500 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1501 |  |  |         $insert = $res[0]['count'] == 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1502 |  |  |         if ($insert) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1503 |  |  |             $q = $this->dbHandler->createInsertQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1504 |  |  |             $q->insertInto($this->dbHandler->quoteTable('ezcontentobject_name')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1505 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1506 |  |  |             $q = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1507 |  |  |             $q->update($this->dbHandler->quoteTable('ezcontentobject_name')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1508 |  |  |                 ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1509 |  |  |                     $q->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1510 |  |  |                         $q->expr->eq($this->dbHandler->quoteColumn('contentobject_id'), $q->bindValue($contentId)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1511 |  |  |                         $q->expr->eq($this->dbHandler->quoteColumn('content_version'), $q->bindValue($version)), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1512 |  |  |                         $q->expr->eq($this->dbHandler->quoteColumn('content_translation'), $q->bindValue($language->languageCode)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1513 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1514 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1515 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1517 |  |  |         $q->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1518 |  |  |             $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1519 |  |  |             $q->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1520 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1521 |  |  |             $this->dbHandler->quoteColumn('content_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1522 |  |  |             $q->bindValue($version, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1523 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1524 |  |  |             $this->dbHandler->quoteColumn('language_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1525 |  |  |             $q->bindValue($language->id, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1526 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1527 |  |  |             $this->dbHandler->quoteColumn('content_translation'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1528 |  |  |             $q->bindValue($language->languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1529 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1530 |  |  |             $this->dbHandler->quoteColumn('real_translation'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1531 |  |  |             $q->bindValue($language->languageCode) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1532 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1533 |  |  |             $this->dbHandler->quoteColumn('name'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1534 |  |  |             $q->bindValue($name) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1535 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1536 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1537 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1538 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1539 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1540 |  |  |      * Deletes the actual content object referred to by $contentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1541 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1542 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1543 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1544 |  |  |     public function deleteContent($contentId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1545 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1546 |  |  |         $query = $this->dbHandler->createDeleteQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1547 |  |  |         $query->deleteFrom('ezcontentobject') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1548 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1549 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1550 |  |  |                     $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1551 |  |  |                     $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1552 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1553 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1554 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1555 |  |  |         $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1556 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1557 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1558 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1559 |  |  |      * Loads relations from $contentId to published content, optionally only from $contentVersionNo. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1560 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1561 |  |  |      * $relationType can also be filtered. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1562 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1563 |  |  |      * @param int $contentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1564 |  |  |      * @param int $contentVersionNo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1565 |  |  |      * @param int $relationType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1566 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1567 |  |  |      * @return string[][] array of relation data | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1568 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1569 |  |  |     public function loadRelations($contentId, $contentVersionNo = null, $relationType = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1570 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1571 |  |  |         $query = $this->queryBuilder->createRelationFindQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1572 |  |  |         $query->innerJoin( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1573 |  |  |             $query->alias( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1574 |  |  |                 $this->dbHandler->quoteTable('ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1575 |  |  |                 'ezcontentobject_to' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1576 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1577 |  |  |             $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1578 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1579 |  |  |                     $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1580 |  |  |                     $this->dbHandler->quoteColumn('id', 'ezcontentobject_to') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1581 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1582 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1583 |  |  |                     $this->dbHandler->quoteColumn('status', 'ezcontentobject_to'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1584 |  |  |                     $query->bindValue(1, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1585 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1586 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1587 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1588 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1589 |  |  |                 $this->dbHandler->quoteColumn('from_contentobject_id', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1590 |  |  |                 $query->bindValue($contentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1591 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1592 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1594 |  |  |         // source version number | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1595 |  |  |         if (isset($contentVersionNo)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1596 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1597 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1598 |  |  |                     $this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1599 |  |  |                     $query->bindValue($contentVersionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1600 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1601 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1602 |  |  |         } else { // from published version only | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1603 |  |  |             $query->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1604 |  |  |                 $this->dbHandler->quoteTable('ezcontentobject') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1605 |  |  |             )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1606 |  |  |                 $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1607 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1608 |  |  |                         $this->dbHandler->quoteColumn('id', 'ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1609 |  |  |                         $this->dbHandler->quoteColumn('from_contentobject_id', 'ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1610 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1611 |  |  |                     $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1612 |  |  |                         $this->dbHandler->quoteColumn('current_version', 'ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1613 |  |  |                         $this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1614 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1615 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1616 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1617 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1618 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1619 |  |  |         // relation type | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1620 |  | View Code Duplication |         if (isset($relationType)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1621 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1622 |  |  |                 $query->expr->gt( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1623 |  |  |                     $query->expr->bitAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1624 |  |  |                         $this->dbHandler->quoteColumn('relation_type', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1625 |  |  |                         $query->bindValue($relationType, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1626 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1627 |  |  |                     0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1628 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1629 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1630 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1631 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1632 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1633 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1634 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1635 |  |  |         return $statement->fetchAll(\PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1636 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1637 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1638 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1639 |  |  |      * Loads data that related to $toContentId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1640 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1641 |  |  |      * @param int $toContentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1642 |  |  |      * @param int $relationType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1643 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1644 |  |  |      * @return mixed[][] Content data, array structured like {@see \eZ\Publish\Core\Persistence\Legacy\Content\Gateway::load()} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1645 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1646 |  |  |     public function loadReverseRelations($toContentId, $relationType = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1647 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1648 |  |  |         $query = $this->queryBuilder->createRelationFindQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1649 |  |  |         $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1650 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1651 |  |  |                 $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1652 |  |  |                 $query->bindValue($toContentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1653 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1654 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1655 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1656 |  |  |         // ezcontentobject join | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1657 |  |  |         $query->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1658 |  |  |             $this->dbHandler->quoteTable('ezcontentobject') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1659 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1660 |  |  |             $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1661 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1662 |  |  |                     $this->dbHandler->quoteColumn('id', 'ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1663 |  |  |                     $this->dbHandler->quoteColumn('from_contentobject_id', 'ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1664 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1665 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1666 |  |  |                     $this->dbHandler->quoteColumn('current_version', 'ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1667 |  |  |                     $this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1668 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1669 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1670 |  |  |                     $this->dbHandler->quoteColumn('status', 'ezcontentobject'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1671 |  |  |                     $query->bindValue(1, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1672 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1673 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1674 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1675 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1676 |  |  |         // relation type | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1677 |  | View Code Duplication |         if (isset($relationType)) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1678 |  |  |             $query->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1679 |  |  |                 $query->expr->gt( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1680 |  |  |                     $query->expr->bitAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1681 |  |  |                         $this->dbHandler->quoteColumn('relation_type', 'ezcontentobject_link'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1682 |  |  |                         $query->bindValue($relationType, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1683 |  |  |                     ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1684 |  |  |                     0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1685 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1686 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1687 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1688 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1689 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1690 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1691 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1692 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1693 |  |  |         return $statement->fetchAll(\PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1694 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1695 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1696 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1697 |  |  |      * Inserts a new relation database record. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1698 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1699 |  |  |      * @param \eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct $createStruct | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1700 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1701 |  |  |      * @return int ID the inserted ID | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1702 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 1703 |  | View Code Duplication |     public function insertRelation(RelationCreateStruct $createStruct) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1704 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1705 |  |  |         $q = $this->dbHandler->createInsertQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1706 |  |  |         $q->insertInto( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1707 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1708 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1709 |  |  |             $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1710 |  |  |             $this->dbHandler->getAutoIncrementValue('ezcontentobject_link', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1711 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1712 |  |  |             $this->dbHandler->quoteColumn('contentclassattribute_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1713 |  |  |             $q->bindValue((int)$createStruct->sourceFieldDefinitionId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1714 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1715 |  |  |             $this->dbHandler->quoteColumn('from_contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1716 |  |  |             $q->bindValue($createStruct->sourceContentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1717 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1718 |  |  |             $this->dbHandler->quoteColumn('from_contentobject_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1719 |  |  |             $q->bindValue($createStruct->sourceContentVersionNo, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1720 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1721 |  |  |             $this->dbHandler->quoteColumn('relation_type'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1722 |  |  |             $q->bindValue($createStruct->type, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1723 |  |  |         )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1724 |  |  |             $this->dbHandler->quoteColumn('to_contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1725 |  |  |             $q->bindValue($createStruct->destinationContentId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1726 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1727 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1728 |  |  |         $q->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1729 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1730 |  |  |         return $this->dbHandler->lastInsertId( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1731 |  |  |             $this->dbHandler->getSequenceName('ezcontentobject_link', 'id') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1732 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1733 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1734 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1735 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1736 |  |  |      * Deletes the relation with the given $relationId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1737 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1738 |  |  |      * @param int $relationId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1739 |  |  |      * @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1740 |  |  |      *                 \eZ\Publish\API\Repository\Values\Content\Relation::EMBED, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1741 |  |  |      *                 \eZ\Publish\API\Repository\Values\Content\Relation::LINK, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1742 |  |  |      *                 \eZ\Publish\API\Repository\Values\Content\Relation::FIELD} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1743 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1744 |  |  |     public function deleteRelation($relationId, $type) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1745 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1746 |  |  |         // Legacy Storage stores COMMON, LINK and EMBED types using bitmask, therefore first load | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1747 |  |  |         // existing relation type by given $relationId for comparison | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1748 |  |  |         /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1749 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1750 |  |  |         $query->select( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1751 |  |  |             $this->dbHandler->quoteColumn('relation_type') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1752 |  |  |         )->from( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1753 |  |  |             $this->dbHandler->quoteTable('ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1754 |  |  |         )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1755 |  |  |             $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1756 |  |  |                 $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1757 |  |  |                 $query->bindValue($relationId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1758 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1759 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1760 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1761 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1762 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1763 |  |  |         $loadedRelationType = $statement->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1764 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1765 |  |  |         if (!$loadedRelationType) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1766 |  |  |             return; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1767 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1768 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1769 |  |  |         // If relation type matches then delete | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1770 |  |  |         if ($loadedRelationType == $type) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1771 |  |  |             /** @var $query \eZ\Publish\Core\Persistence\Database\DeleteQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1772 |  |  |             $query = $this->dbHandler->createDeleteQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1773 |  |  |             $query->deleteFrom( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1774 |  |  |                 'ezcontentobject_link' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1775 |  |  |             )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1776 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1777 |  |  |                     $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1778 |  |  |                     $query->bindValue($relationId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1779 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1780 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1781 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1782 |  |  |             $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1783 |  |  |         } elseif ($loadedRelationType & $type) { // If relation type is composite update bitmask | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1784 |  |  |             /** @var $query \eZ\Publish\Core\Persistence\Database\UpdateQuery */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1785 |  |  |             $query = $this->dbHandler->createUpdateQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1786 |  |  |             $query->update( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1787 |  |  |                 $this->dbHandler->quoteTable('ezcontentobject_link') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1788 |  |  |             )->set( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1789 |  |  |                 $this->dbHandler->quoteColumn('relation_type'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1790 |  |  |                 $query->expr->bitAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1791 |  |  |                     $this->dbHandler->quoteColumn('relation_type'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1792 |  |  |                     $query->bindValue(~$type, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1793 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1794 |  |  |             )->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1795 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1796 |  |  |                     $this->dbHandler->quoteColumn('id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1797 |  |  |                     $query->bindValue($relationId, null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1798 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1799 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1800 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1801 |  |  |             $query->prepare()->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1802 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1803 |  |  |             // No match, do nothing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1804 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1805 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1806 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1807 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1808 |  |  |      * Returns all Content IDs for a given $contentTypeId. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1809 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1810 |  |  |      * @param int $contentTypeId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1811 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1812 |  |  |      * @return int[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1813 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1814 |  |  |     public function getContentIdsByContentTypeId($contentTypeId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1815 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1816 |  |  |         $query = $this->dbHandler->createSelectQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1817 |  |  |         $query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1818 |  |  |             ->select($this->dbHandler->quoteColumn('id')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1819 |  |  |             ->from($this->dbHandler->quoteTable('ezcontentobject')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1820 |  |  |             ->where( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1821 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1822 |  |  |                     $this->dbHandler->quoteColumn('contentclass_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1823 |  |  |                     $query->bindValue($contentTypeId, null, PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1824 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1825 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1826 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1827 |  |  |         $statement = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1828 |  |  |         $statement->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1829 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1830 |  |  |         return $statement->fetchAll(PDO::FETCH_COLUMN); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1831 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1832 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1833 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1834 |  |  |      * Load name data for set of content id's and corresponding version number. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1835 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1836 |  |  |      * @param array[] $rows array of hashes with 'id' and 'version' to load names for | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1837 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1838 |  |  |      * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1839 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1840 |  |  |     public function loadVersionedNameData($rows) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1841 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1842 |  |  |         $query = $this->queryBuilder->createNamesQuery(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1843 |  |  |         $conditions = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1844 |  |  |         foreach ($rows as $row) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1845 |  |  |             $conditions[] = $query->expr->lAnd( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1846 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1847 |  |  |                     $this->dbHandler->quoteColumn('contentobject_id'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1848 |  |  |                     $query->bindValue($row['id'], null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1849 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1850 |  |  |                 $query->expr->eq( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1851 |  |  |                     $this->dbHandler->quoteColumn('content_version'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1852 |  |  |                     $query->bindValue($row['version'], null, \PDO::PARAM_INT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1853 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1854 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1855 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1856 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1857 |  |  |         $query->where($query->expr->lOr($conditions)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1858 |  |  |         $stmt = $query->prepare(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1859 |  |  |         $stmt->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1860 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1861 |  |  |         return $stmt->fetchAll(\PDO::FETCH_ASSOC); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1862 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1863 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1864 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1865 |  |  |      * Batch method for copying all relation meta data for copied Content object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1866 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1867 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1868 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1869 |  |  |      * @param int $originalContentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1870 |  |  |      * @param int $copiedContentId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1871 |  |  |      * @param int|null $versionNo If specified only copy for a given version number, otherwise all. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1872 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1873 |  |  |     public function copyRelations($originalContentId, $copiedContentId, $versionNo = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1874 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1875 |  |  |         // Given we can retain all columns, we just create copies with new `from_contentobject_id` using INSERT INTO SELECT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1876 |  |  |         $sql = 'INSERT INTO ezcontentobject_link ( contentclassattribute_id, from_contentobject_id, from_contentobject_version, relation_type, to_contentobject_id ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1877 |  |  |                 SELECT  L2.contentclassattribute_id, :copied_id, L2.from_contentobject_version, L2.relation_type, L2.to_contentobject_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1878 |  |  |                 FROM    ezcontentobject_link AS L2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1879 |  |  |                 WHERE   L2.from_contentobject_id = :original_id'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1880 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1881 |  |  |         if ($versionNo) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1882 |  |  |             $stmt = $this->connection->prepare($sql . ' AND L2.from_contentobject_version = :version'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1883 |  |  |             $stmt->bindValue('version', $versionNo, PDO::PARAM_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1884 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1885 |  |  |             $stmt = $this->connection->prepare($sql); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1886 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1887 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1888 |  |  |         $stmt->bindValue('original_id', $originalContentId, PDO::PARAM_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1889 |  |  |         $stmt->bindValue('copied_id', $copiedContentId, PDO::PARAM_INT); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1890 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1891 |  |  |         $stmt->execute(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 1892 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 1893 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 1894 |  |  |  | 
            
                        
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.