Neos\ContentRepository\Domain\Repository\NodeDataRepository::add PHP Method

add() public method

This repository keeps track of added and removed nodes (additionally to the other Unit of Work) in order to find in-memory nodes.
public add ( object $object ) : void
$object object The object to add
return void
    public function add($object)
    {
        if ($this->removedNodes->contains($object)) {
            $this->removedNodes->detach($object);
        }
        if (!$this->addedNodes->contains($object)) {
            $this->addedNodes->attach($object);
        }
        parent::add($object);
    }

Usage Example

 /**
  * Materializes the original node data (of a different workspace) into the current
  * workspace.
  *
  * @return void
  */
 protected function materializeNodeData()
 {
     $dimensions = $this->context->getTargetDimensionValues();
     $newNodeData = new NodeData($this->nodeData->getPath(), $this->context->getWorkspace(), $this->nodeData->getIdentifier(), $dimensions);
     $this->nodeDataRepository->add($newNodeData);
     $newNodeData->similarize($this->nodeData);
     $this->nodeData = $newNodeData;
     $this->nodeDataIsMatchingContext = true;
     $nodeType = $this->getNodeType();
     foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
         $childNode = $this->getNode($childNodeName);
         if ($childNode instanceof Node && !$childNode->isNodeDataMatchingContext()) {
             $childNode->materializeNodeData();
         }
     }
 }
All Usage Examples Of Neos\ContentRepository\Domain\Repository\NodeDataRepository::add