/**
  * Gets and registers a new reference.
  *
  * @param \TYPO3\CMS\Version\Dependency\ElementEntity $element
  * @param string $field
  * @return \TYPO3\CMS\Version\Dependency\ReferenceEntity
  */
 public function getReference(\TYPO3\CMS\Version\Dependency\ElementEntity $element, $field)
 {
     $referenceName = $element->__toString() . '.' . $field;
     if (!isset($this->references[$referenceName][$field])) {
         $this->references[$referenceName][$field] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Version\\Dependency\\ReferenceEntity', $element, $field);
     }
     return $this->references[$referenceName][$field];
 }
Ejemplo n.º 2
0
 /**
  * Gets all nested elements (including the parent) of a particular outermost parent element.
  *
  * @throws \RuntimeException
  * @param \TYPO3\CMS\Version\Dependency\ElementEntity $outerMostParent
  * @return array
  */
 public function getNestedElements(\TYPO3\CMS\Version\Dependency\ElementEntity $outerMostParent)
 {
     $outerMostParentName = $outerMostParent->__toString();
     if (!isset($this->outerMostParents[$outerMostParentName])) {
         throw new \RuntimeException('Element "' . $outerMostParentName . '" was not detected as outermost parent.', 1289318609);
     }
     $nestedStructure = array_merge(array($outerMostParentName => $outerMostParent), $outerMostParent->getNestedChildren());
     return $nestedStructure;
 }
Ejemplo n.º 3
0
 /**
  * Callback to add additional data to new elements created in the dependency resolver utility.
  *
  * @throws \RuntimeException
  * @param ElementEntity $caller
  * @param array $callerArguments
  * @param array $targetArgument
  * @param string $eventName
  * @return void
  */
 public function createNewDependentElementCallback(array $callerArguments, array $targetArgument, ElementEntity $caller, $eventName)
 {
     if (!BackendUtility::isTableWorkspaceEnabled($caller->getTable())) {
         $caller->setInvalid(true);
         return;
     }
     $versionRecord = $caller->getRecord();
     // If version record does not exist, it probably has been deleted (cleared from workspace), this means,
     // that the reference index still has an old reference pointer, which is "fine" for deleted parents
     if (empty($versionRecord)) {
         throw new \RuntimeException('Element "' . $caller::getIdentifier($caller->getTable(), $caller->getId()) . '" does not exist', 1393960943);
     }
     // If version is on live workspace, but the pid is negative, mark the record as invalid.
     // This happens if a change has been discarded (clearWSID) - it will be removed from the command map.
     if ((int) $versionRecord['t3ver_wsid'] === 0 && (int) $versionRecord['pid'] === -1) {
         $caller->setDataValue('liveId', $caller->getId());
         $caller->setInvalid(true);
         return;
     }
     if ($caller->hasDataValue('liveId') === false) {
         // Set the original uid from the version record
         if (!empty($versionRecord['t3ver_oid']) && (int) $versionRecord['pid'] === -1 && (int) $versionRecord['t3ver_wsid'] === $this->getWorkspace()) {
             $caller->setDataValue('liveId', $versionRecord['t3ver_oid']);
             // The current version record is actually a live record or an accordant placeholder for live
         } elseif ((int) $versionRecord['t3ver_wsid'] === 0 || (int) $versionRecord['pid'] !== -1) {
             $caller->setDataValue('liveId', $caller->getId());
             $versionRecord = BackendUtility::getWorkspaceVersionOfRecord($this->getWorkspace(), $caller->getTable(), $caller->getId(), 'uid,t3ver_state');
             // Set version uid to caller, most likely it's a delete placeholder
             // for a child record that is not recognized in the reference index
             if (!empty($versionRecord['uid'])) {
                 $caller->setId($versionRecord['uid']);
                 // If no version could be determined, mark record as invalid
                 // (thus, it will be removed from the command map)
             } else {
                 $caller->setInvalid(true);
             }
             // In case of an unexpected record state, mark the record as invalid
         } else {
             $caller->setInvalid(true);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * Resolves nested child dependencies.
  *
  * @param Dependency\ElementEntity $parent
  * @param int $collection
  * @param string $nextParentIdentifier
  * @param int $collectionLevel
  */
 protected function resolveDataArrayChildDependencies(Dependency\ElementEntity $parent, $collection, $nextParentIdentifier = '', $collectionLevel = 0)
 {
     $parentIdentifier = $parent->__toString();
     $parentIsSet = isset($this->dataArray[$parentIdentifier]);
     if ($parentIsSet) {
         $this->dataArray[$parentIdentifier][GridDataService::GridColumn_Collection] = $collection;
         $this->dataArray[$parentIdentifier][GridDataService::GridColumn_CollectionLevel] = $collectionLevel;
         $this->dataArray[$parentIdentifier][GridDataService::GridColumn_CollectionCurrent] = md5($parentIdentifier);
         $this->dataArray[$parentIdentifier][GridDataService::GridColumn_CollectionChildren] = count($parent->getChildren());
         $nextParentIdentifier = $parentIdentifier;
         $collectionLevel++;
     }
     foreach ($parent->getChildren() as $child) {
         $this->resolveDataArrayChildDependencies($child->getElement(), $collection, $nextParentIdentifier, $collectionLevel);
         $childIdentifier = $child->getElement()->__toString();
         if (!empty($nextParentIdentifier) && isset($this->dataArray[$childIdentifier])) {
             // Remove from dataArray, but collect to process later
             // and add it just next to the accordant parent element
             $this->dataArray[$childIdentifier][GridDataService::GridColumn_CollectionParent] = md5($nextParentIdentifier);
             $this->nestedDataArray[$nextParentIdentifier][] = $this->dataArray[$childIdentifier];
             unset($this->dataArray[$childIdentifier]);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Callback to get common properties of dependent elements for staging.
  *
  * @param ElementEntity $element
  * @return array
  */
 protected function getCommonSetStagePropertiesCallback(ElementEntity $element)
 {
     $commonSetStageProperties = array();
     $elementProperties = $element->getDataValue('properties');
     if (isset($elementProperties['stageId'])) {
         $commonSetStageProperties['stageId'] = $elementProperties['stageId'];
     }
     if (isset($elementProperties['comment'])) {
         $commonSetStageProperties['comment'] = $elementProperties['comment'];
     }
     if (isset($elementProperties['action'])) {
         $commonSetStageProperties['action'] = $elementProperties['action'];
     }
     if (isset($elementProperties['notificationAlternativeRecipients'])) {
         $commonSetStageProperties['notificationAlternativeRecipients'] = $elementProperties['notificationAlternativeRecipients'];
     }
     return $commonSetStageProperties;
 }