/**
  * Change the property on the given node.
  *
  * @param \TYPO3\TYPO3CR\Domain\Model\NodeData $nodeData
  * @return void
  */
 public function execute(NodeData $nodeData)
 {
     $dimensions = $nodeData->getDimensions();
     if ($dimensions !== array()) {
         $hasChanges = false;
         $newDimensions = array();
         foreach ($dimensions as $dimension) {
             /** @var NodeDimension $dimension */
             if ($dimension->getName() === $this->oldDimensionName) {
                 $dimension = new NodeDimension($dimension->getNodeData(), $this->newDimensionName, $dimension->getValue());
                 $hasChanges = true;
             } else {
                 $dimension = new NodeDimension($dimension->getNodeData(), $dimension->getName(), $dimension->getValue());
             }
             $newDimensions[] = $dimension;
         }
         if ($hasChanges) {
             $nodeData->setDimensions($newDimensions);
         }
     }
 }
 /**
  * Internal method used in setDimensions to reuse dimension objects with the same name/value pair.
  *
  * @param NodeDimension $dimensionToBeSet
  * @return NodeDimension|null
  * @see setDimensions
  */
 protected function findExistingDimensionMatching(NodeDimension $dimensionToBeSet)
 {
     return array_reduce($this->dimensions->toArray(), function ($found, NodeDimension $dimension) use($dimensionToBeSet) {
         if ($found === null && $dimension->getName() === $dimensionToBeSet->getName() && $dimensionToBeSet->getValue() === $dimension->getValue()) {
             $found = $dimension;
         }
         return $found;
     }, null);
 }