コード例 #1
0
 /**
  * @return Dependency\DependencyResolver
  */
 public function getDependencyResolver()
 {
     if (!isset($this->dependencyResolver)) {
         $this->dependencyResolver = GeneralUtility::makeInstance('TYPO3\\CMS\\Version\\Dependency\\DependencyResolver');
         $this->dependencyResolver->setOuterMostParentsRequireReferences(TRUE);
         $this->dependencyResolver->setWorkspace($this->getWorkspace());
         $this->dependencyResolver->setEventCallback(Dependency\ElementEntity::EVENT_CreateChildReference, $this->getDependencyCallback('createNewDependentElementChildReferenceCallback'));
         $this->dependencyResolver->setEventCallback(Dependency\ElementEntity::EVENT_CreateParentReference, $this->getDependencyCallback('createNewDependentElementParentReferenceCallback'));
     }
     return $this->dependencyResolver;
 }
コード例 #2
0
 /**
  * Gets all parent references.
  *
  * @return array|ReferenceEntity[]
  */
 public function getParents()
 {
     if (!isset($this->parents)) {
         $this->parents = [];
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
         $result = $queryBuilder->select('*')->from('sys_refindex')->where($queryBuilder->expr()->eq('deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('ref_table', $queryBuilder->createNamedParameter($this->table, \PDO::PARAM_STR)), $queryBuilder->expr()->eq('ref_uid', $queryBuilder->createNamedParameter($this->id, \PDO::PARAM_INT)), $queryBuilder->expr()->eq('workspace', $queryBuilder->createNamedParameter($this->dependency->getWorkspace(), \PDO::PARAM_INT)))->orderBy('sorting')->execute();
         while ($row = $result->fetch()) {
             $arguments = ['table' => $row['tablename'], 'id' => $row['recuid'], 'field' => $row['field'], 'scope' => self::REFERENCES_ParentOf];
             $callbackResponse = $this->dependency->executeEventCallback(self::EVENT_CreateParentReference, $this, $arguments);
             if ($callbackResponse !== self::RESPONSE_Skip) {
                 $this->parents[] = $this->getDependency()->getFactory()->getReferencedElement($row['tablename'], $row['recuid'], $row['field'], [], $this->getDependency());
             }
         }
     }
     return $this->parents;
 }
コード例 #3
0
ファイル: ElementEntity.php プロジェクト: plan2net/TYPO3.CMS
 /**
  * Gets all parent references.
  *
  * @return array|ReferenceEntity[]
  */
 public function getParents()
 {
     if (!isset($this->parents)) {
         $this->parents = array();
         $where = 'ref_table=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->table, 'sys_refindex') . ' AND deleted=0 AND ref_uid=' . $this->id . ' AND workspace=' . $this->dependency->getWorkspace();
         $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', $where, '', 'sorting');
         if (is_array($rows)) {
             foreach ($rows as $row) {
                 $arguments = array('table' => $row['tablename'], 'id' => $row['recuid'], 'field' => $row['field'], 'scope' => self::REFERENCES_ParentOf);
                 $callbackResponse = $this->dependency->executeEventCallback(self::EVENT_CreateParentReference, $this, $arguments);
                 if ($callbackResponse !== self::RESPONSE_Skip) {
                     $this->parents[] = $this->getDependency()->getFactory()->getReferencedElement($row['tablename'], $row['recuid'], $row['field'], array(), $this->getDependency());
                 }
             }
         }
     }
     return $this->parents;
 }
コード例 #4
0
 /**
  * Applies the workspaces dependencies and removes incomplete structures or automatically
  * completes them, depending on the options.workspaces.considerReferences setting
  *
  * @param \TYPO3\CMS\Version\Dependency\DependencyResolver $dependency
  * @param string $scope
  * @return void
  */
 protected function applyWorkspacesDependencies(\TYPO3\CMS\Version\Dependency\DependencyResolver $dependency, $scope)
 {
     $transformDependentElementsToUseLiveId = $this->getScopeData($scope, self::KEY_TransformDependentElementsToUseLiveId);
     $elementsToBeVersioned = $dependency->getElements();
     // Use the uid of the live record instead of the workspace record:
     if ($transformDependentElementsToUseLiveId) {
         $elementsToBeVersioned = $this->getElementEntityProcessor()->transformDependentElementsToUseLiveId($elementsToBeVersioned);
     }
     $outerMostParents = $dependency->getOuterMostParents();
     /** @var $outerMostParent ElementEntity */
     foreach ($outerMostParents as $outerMostParent) {
         $dependentElements = $dependency->getNestedElements($outerMostParent);
         if ($transformDependentElementsToUseLiveId) {
             $dependentElements = $this->getElementEntityProcessor()->transformDependentElementsToUseLiveId($dependentElements);
         }
         // Gets the difference (intersection) between elements that were submitted by the user
         // and the evaluation of all dependent records that should be used for this action instead:
         $intersectingElements = array_intersect_key($dependentElements, $elementsToBeVersioned);
         if (!empty($intersectingElements)) {
             // If at least one element intersects but not all, throw away all elements of the depdendent structure:
             if (count($intersectingElements) !== count($dependentElements) && $this->workspacesConsiderReferences === false) {
                 $this->purgeWithErrorMessage($intersectingElements, $scope);
             } else {
                 $this->update(current($intersectingElements), $dependentElements, $scope);
             }
         }
     }
 }