getNodesByIdentifier() public method

This is an optimization over getNodeByIdentifier to get many nodes in one call. If the transport implementation does not optimize, it can just loop over the uuids and call getNodeByIdentifier repeatedly.
public getNodesByIdentifier ( array $identifiers ) : array
$identifiers array list of uuid to retrieve
return array keys are the absolute paths, values is the node data as associative array (decoded from json with associative = true). they will have the identifier value set.
Exemplo n.º 1
0
 /**
  * Get the nodes identified by the given UUIDs.
  *
  * Note UUIDs that are not found will be ignored. Also, duplicate IDs
  * will be eliminated by nature of using the IDs as keys.
  *
  * @param array  $identifiers UUIDs of nodes to retrieve.
  * @param string $class       Optional class name for the factory.
  *
  * @return Node[] Iterator of the specified nodes keyed by their unique ids
  *
  * @throws RepositoryException if another error occurs.
  *
  * @see Session::getNodesByIdentifier()
  */
 public function getNodesByIdentifier($identifiers, $class = 'Node')
 {
     $nodes = $fetchPaths = array();
     foreach ($identifiers as $uuid) {
         if (!empty($this->objectsByUuid[$uuid]) && !empty($this->objectsByPath[$class][$this->objectsByUuid[$uuid]])) {
             // Return it from memory if we already have it
             $nodes[$uuid] = $this->objectsByPath[$class][$this->objectsByUuid[$uuid]];
         } else {
             $fetchPaths[$uuid] = $uuid;
             $nodes[$uuid] = $uuid;
             // keep position
         }
     }
     if (!empty($fetchPaths)) {
         $data = $this->transport->getNodesByIdentifier($fetchPaths);
         foreach ($data as $absPath => $item) {
             // TODO: $absPath is the backend path. we should inverse the getFetchPath operation here
             // build the node from the received data
             $node = $this->getNodeByPath($absPath, $class, $item);
             $found[$node->getIdentifier()] = $node;
         }
         foreach ($nodes as $key => $node) {
             if (is_string($node)) {
                 if (isset($found[$node])) {
                     $nodes[$key] = $found[$node];
                 } else {
                     unset($nodes[$key]);
                 }
             }
         }
     }
     reset($nodes);
     return new ArrayIterator($nodes);
 }
 /**
  * {@inheritDoc}
  */
 public function getNodesByIdentifier($identifiers)
 {
     $this->logger->startCall(__FUNCTION__, func_get_args(), array('fetchDepth' => $this->transport->getFetchDepth()));
     $result = $this->transport->getNodesByIdentifier($identifiers);
     $this->logger->stopCall();
     return $result;
 }