Neos.ContentRepository/Classes/Domain/Model/NodeData.php
public function setDimensions(array $dimensionsToBeSet)
    {
        if ($this->dimensions->count() === 0) {
            $this->dimensions = new ArrayCollection($dimensionsToBeSet);
            $this->buildDimensionValues();
            return;
        }

        $expectedDimensions = [];
        /** @var NodeDimension $dimensionToBeSet */
        foreach ($dimensionsToBeSet as $dimensionToBeSet) {
            $dimensionToBeSet->setNodeData($this);
            $existingDimension = $this->findExistingDimensionMatching($dimensionToBeSet);
            $expectedDimensions[] = $existingDimension !== null ? $existingDimension : $dimensionToBeSet;
            if ($existingDimension === null) {
                $this->dimensions->add($dimensionToBeSet);
            }
        }

        // remove entries not to be set
        $dimensionsToRemove = $this->dimensions->filter(function (NodeDimension $dimension) use ($expectedDimensions) {
            return (array_search($dimension, $expectedDimensions) === false);
        });

        foreach ($dimensionsToRemove as $dimension) {
            $this->dimensions->removeElement($dimension);
        }

        $this->buildDimensionValues();
    }
public function setDimensions(array $dimensionsToBeSet)
    {
        if ($this->dimensions->count() === 0) {
            $this->dimensions = new ArrayCollection($dimensionsToBeSet);
            $this->buildDimensionValues();
            return;
        }

        $expectedDimensions = [];
        /** @var NodeDimension $dimensionToBeSet */
        foreach ($dimensionsToBeSet as $dimensionToBeSet) {
            $dimensionToBeSet->setNodeData($this);
            $existingDimension = $this->findExistingDimensionMatching($dimensionToBeSet);
            $expectedDimensions[] = $existingDimension !== null ? $existingDimension : $dimensionToBeSet;
            if ($existingDimension === null) {
                $this->dimensions->add($dimensionToBeSet);
            }
        }

        // remove entries not to be set
        $dimensionsToRemove = $this->dimensions->filter(function (NodeDimension $dimension) use ($expectedDimensions) {
            return (array_search($dimension, $expectedDimensions) === false);
        });

        foreach ($dimensionsToRemove as $dimension) {
            $this->dimensions->removeElement($dimension);
        }

        $this->buildDimensionValues();
    }
public function setDimensions ( array $ dimensionsToBeSet ) { if ( $ this -> dimensions -> count ( ) === 0 ) { $ this -> dimensions = new ArrayCollection ( $ dimensionsToBeSet ) ; $ this -> buildDimensionValues ( ) ; return ; } $ expectedDimensions = [ ] ; /** @var NodeDimension $dimensionToBeSet */ foreach ( $ dimensionsToBeSet as $ dimensionToBeSet ) { $ dimensionToBeSet -> setNodeData ( $ this ) ; $ existingDimension = $ this -> findExistingDimensionMatching ( $ dimensionToBeSet ) ; $ expectedDimensions [ ] = $ existingDimension !== null ? $ existingDimension : $ dimensionToBeSet ; if ( $ existingDimension === null ) { $ this -> dimensions -> add ( $ dimensionToBeSet ) ; } } // remove entries not to be set $ dimensionsToRemove = $ this -> dimensions -> filter ( function ( NodeDimension $ dimension ) use ( $ expectedDimensions ) { return ( array_search ( $ dimension , $ expectedDimensions ) === false ) ; } ) ; foreach ( $ dimensionsToRemove as $ dimension ) { $ this -> dimensions -> removeElement ( $ dimension ) ; } $ this -> buildDimensionValues ( ) ; }
Internal use, do not manipulate collection directly

@param array <NodeDimension> $dimensionsToBeSet
@return void
Internal use do not manipulate collection directly