getTargetDimensions() public method

An indexed array of dimensions with a set of values that should be applied when updating or creating
public getTargetDimensions ( ) : array
return array
Ejemplo n.º 1
0
 /**
  * Internal method
  *
  * The dimension value of this node has to match the current target dimension value (must be higher in priority or equal)
  *
  * @return boolean
  */
 public function dimensionsAreMatchingTargetDimensionValues()
 {
     $dimensions = $this->getDimensions();
     $contextDimensions = $this->context->getDimensions();
     foreach ($this->context->getTargetDimensions() as $dimensionName => $targetDimensionValue) {
         if (!isset($dimensions[$dimensionName])) {
             if ($targetDimensionValue === null) {
                 continue;
             } else {
                 return false;
             }
         } elseif ($targetDimensionValue === null && $dimensions[$dimensionName] === array()) {
             continue;
         } elseif (!in_array($targetDimensionValue, $dimensions[$dimensionName], true)) {
             $contextDimensionValues = $contextDimensions[$dimensionName];
             $targetPositionInContext = array_search($targetDimensionValue, $contextDimensionValues, true);
             $nodePositionInContext = min(array_map(function ($value) use($contextDimensionValues) {
                 return array_search($value, $contextDimensionValues, true);
             }, $dimensions[$dimensionName]));
             $val = $targetPositionInContext !== false && $nodePositionInContext !== false && $targetPositionInContext >= $nodePositionInContext;
             if ($val === false) {
                 return false;
             }
         }
     }
     return true;
 }
 /**
  *
  *
  * @param NodeInterface $node
  * @param Context $context
  * @param $recursive
  * @return void
  */
 public function beforeAdoptNode(NodeInterface $node, Context $context, $recursive)
 {
     if (!$this->eventEmittingService->isEnabled()) {
         return;
     }
     $this->initializeAccountIdentifier();
     if ($this->currentlyAdopting === 0) {
         /* @var $nodeEvent NodeEvent */
         $nodeEvent = $this->eventEmittingService->emit(self::NODE_ADOPT, array('targetWorkspace' => $context->getWorkspaceName(), 'targetDimensions' => $context->getTargetDimensions(), 'recursive' => $recursive), NodeEvent::class);
         $nodeEvent->setNode($node);
         $this->eventEmittingService->pushContext();
     }
     $this->currentlyAdopting++;
 }