getIdentifier() public method

This UUID is not the same as the technical persistence identifier used by Flow's persistence framework. It is an additional identifier which is unique within the same workspace and is used for tracking the same node in across workspaces. It is okay and recommended to use this identifier for synchronisation purposes as it does not change even if all of the nodes content or its path changes.
public getIdentifier ( ) : string
return string the node's UUID
コード例 #1
0
 /**
  * Given a context a new node is returned that is like this node, but
  * lives in the new context.
  *
  * @param Context $context
  * @return NodeInterface
  */
 public function createVariantForContext($context)
 {
     $autoCreatedChildNodes = [];
     $nodeType = $this->getNodeType();
     foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
         $childNode = $this->getNode($childNodeName);
         if ($childNode !== null) {
             $autoCreatedChildNodes[$childNodeName] = $childNode;
         }
     }
     $nodeData = new NodeData($this->nodeData->getPath(), $context->getWorkspace(), $this->nodeData->getIdentifier(), $context->getTargetDimensionValues());
     $nodeData->similarize($this->nodeData);
     if ($this->context !== $context) {
         $node = $this->nodeFactory->createFromNodeData($nodeData, $context);
     } else {
         $this->setNodeData($nodeData);
         $node = $this;
     }
     $this->context->getFirstLevelNodeCache()->flush();
     $this->emitNodeAdded($node);
     /**
      * @var $autoCreatedChildNode NodeInterface
      */
     foreach ($autoCreatedChildNodes as $autoCreatedChildNode) {
         $autoCreatedChildNode->createVariantForContext($context);
     }
     return $node;
 }
コード例 #2
0
 /**
  * @test
  */
 public function constructorSetsPathWorkspaceAndIdentifier()
 {
     $node = new NodeData('/foo/bar', $this->mockWorkspace, '12345abcde');
     $this->assertSame('/foo/bar', $node->getPath());
     $this->assertSame('bar', $node->getName());
     $this->assertSame($this->mockWorkspace, $node->getWorkspace());
     $this->assertSame('12345abcde', $node->getIdentifier());
 }
コード例 #3
0
 /**
  * Creates a node from the given NodeData container.
  *
  * If this factory has previously created a Node for the given $node and it's dimensions,
  * it will return the same node again.
  *
  * @param NodeData $nodeData
  * @param Context $context
  * @return NodeInterface
  * @throws NodeConfigurationException if a configured 'class' for a Node does not exist or does not inherit NodeInterface
  */
 public function createFromNodeData(NodeData $nodeData, Context $context)
 {
     if ($nodeData->isInternal()) {
         return null;
     }
     $internalNodeIdentifier = $nodeData->getIdentifier() . spl_object_hash($context);
     // In case there is a Node with an internal NodeData (because the NodeData was changed in the meantime) we need to flush it.
     if (isset($this->nodes[$internalNodeIdentifier]) && $this->nodes[$internalNodeIdentifier]->getNodeData()->isInternal()) {
         unset($this->nodes[$internalNodeIdentifier]);
     }
     if (!isset($this->nodes[$internalNodeIdentifier])) {
         // Warning: Alternative node implementations are considered internal for now, feature can change or be removed anytime. We want to be sure it works well and makes sense before declaring it public.
         $class = $nodeData->getNodeType()->getConfiguration('class') ?: $this->objectManager->getClassNameByObjectName(NodeInterface::class);
         if (!in_array($class, static::getNodeInterfaceImplementations($this->objectManager))) {
             throw new NodeConfigurationException('The configured implementation class name "' . $class . '" for NodeType "' . $nodeData->getNodeType() . '" does not inherit from ' . NodeInterface::class . '.', 1406884014);
         }
         $this->nodes[$internalNodeIdentifier] = new $class($nodeData, $context);
     }
     $node = $this->nodes[$internalNodeIdentifier];
     return $this->filterNodeByContext($node, $context);
 }
コード例 #4
0
 /**
  * Adjust the given $shadowNodeData by removing it or moving it to the $targetWorkspace, as needed.
  *
  * @param NodeData $shadowNodeData
  * @param NodeData $publishedNodeData
  * @param Workspace $targetWorkspace
  * @param NodeData $targetNodeData
  * @return void
  */
 protected function adjustShadowNodeData(NodeData $shadowNodeData, NodeData $publishedNodeData, Workspace $targetWorkspace, NodeData $targetNodeData)
 {
     $nodeOnSamePathInTargetWorkspace = $this->nodeDataRepository->findOneByPath($shadowNodeData->getPath(), $targetWorkspace, $publishedNodeData->getDimensionValues());
     if ($nodeOnSamePathInTargetWorkspace !== null && $nodeOnSamePathInTargetWorkspace->getWorkspace() === $targetWorkspace) {
         $this->nodeDataRepository->remove($shadowNodeData);
         return;
     }
     $shadowNodeData->setMovedTo($targetNodeData);
     $shadowNodeData->setWorkspace($targetWorkspace);
     $targetWorkspaceBase = $targetWorkspace->getBaseWorkspace();
     $nodeInTargetWorkspaceBase = $this->nodeDataRepository->findOneByIdentifier($publishedNodeData->getIdentifier(), $targetWorkspaceBase, $publishedNodeData->getDimensionValues());
     if ($nodeInTargetWorkspaceBase !== null && $nodeInTargetWorkspaceBase->getPath() !== $shadowNodeData->getPath()) {
         $this->adjustShadowNodePath($shadowNodeData, $nodeInTargetWorkspaceBase->getPath(), $targetWorkspace, $publishedNodeData->getDimensionValues());
     }
 }