setDimensions() public method

Internal use, do not manipulate collection directly
public setDimensions ( array $dimensionsToBeSet ) : void
$dimensionsToBeSet array
return void
 /**
  * Change the property on the given node.
  *
  * @param NodeData $node
  * @return void
  */
 public function execute(NodeData $node)
 {
     $dimensions = array();
     foreach ($this->dimensionValues as $dimensionName => $dimensionConfiguration) {
         foreach ($dimensionConfiguration as $dimensionValues) {
             if (is_array($dimensionValues)) {
                 foreach ($dimensionValues as $dimensionValue) {
                     $dimensions[] = new NodeDimension($node, $dimensionName, $dimensionValue);
                 }
             } else {
                 $dimensions[] = new NodeDimension($node, $dimensionName, $dimensionValues);
             }
         }
     }
     if ($this->addDefaultDimensionValues === true) {
         $configuredDimensions = $this->contentDimensionRepository->findAll();
         foreach ($configuredDimensions as $configuredDimension) {
             if (!isset($this->dimensionValues[$configuredDimension->getIdentifier()])) {
                 $dimensions[] = new NodeDimension($node, $configuredDimension->getIdentifier(), $configuredDimension->getDefault());
             }
         }
     }
     $node->setDimensions($dimensions);
 }
 /**
  * Change the property on the given node.
  *
  * @param 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);
         }
     }
 }
 /**
  * @test
  */
 public function setDimensionsRemovesDimensionValuesNotGiven()
 {
     $nodeData = new NodeData('/foo/bar', $this->mockWorkspace, null, array('c' => array('c1', 'c2'), 'a' => array('a1')));
     $dimensionsToSet = array(new NodeDimension($nodeData, 'c', 'c1'), new NodeDimension($nodeData, 'b', 'b1'), new NodeDimension($nodeData, 'f', 'f1'));
     $expectedDimensionValues = array('b' => array('b1'), 'c' => array('c1'), 'f' => array('f1'));
     $nodeData->setDimensions($dimensionsToSet);
     $setDimensionValues = $nodeData->getDimensionValues();
     $this->assertSame($expectedDimensionValues, $setDimensionValues);
 }