getNode() public method

Returns a json_decode stdClass structure that contains two fields for each property and one field for each child. A child is just containing an empty class as value (in the future we could use this for eager loading with recursive structure). A property consists of a field named as the property is and a value that is the property value, plus a second field with the same name but prefixed with a colon that has a type specified as value (out of the string constants from PropertyType) For binary properties, the value of the type declaration is not the type but the length of the binary, thus integer instead of string. There is no value field for binary data (to avoid loading large amount of unneeded data) Use getBinaryStream to get the actual data of a binary property. If prefetch is active, eventual children to be cached may be included as stdClass children. This can be several levels deep, depending on the prefetch setting. There is a couple of "magic" properties:
  • jcr:uuid - the unique id of the node
  • jcr:primaryType - name of the primary type
  • jcr:mixinTypes - comma separated list of mixin types
  • jcr:index - the index of same name siblings
public getNode ( string $path ) : array
$path string Absolute path to the node.
return array associative array for the node (decoded from json with associative = true)
 /**
  * {@inheritDoc}
  */
 public function getNode($path)
 {
     $this->logger->startCall(__FUNCTION__, func_get_args(), array('fetchDepth' => $this->transport->getFetchDepth()));
     $result = $this->transport->getNode($path);
     $this->logger->stopCall();
     return $result;
 }
Esempio n. 2
0
 /**
  * Get the node identified by an absolute path.
  *
  * To prevent unnecessary work to be done a cache is filled to only fetch
  * nodes once. To reset a node with the data from the backend, use
  * Node::refresh()
  *
  * Uses the factory to create a Node object.
  *
  * @param string $absPath The absolute path of the node to fetch.
  * @param string $class   The class of node to get. TODO: Is it sane to fetch
  *      data separately for Version and normal Node?
  * @param object $object A (prefetched) object (de-serialized json) from the backend
  *      only to be used if we get child nodes in one backend call
  *
  * @return NodeInterface
  *
  * @throws ItemNotFoundException If nothing is found at that
  *      absolute path
  * @throws RepositoryException If the path is not absolute or not
  *      well-formed
  *
  * @see Session::getNode()
  */
 public function getNodeByPath($absPath, $class = 'Node', $object = null)
 {
     $absPath = PathHelper::normalizePath($absPath);
     if (!empty($this->objectsByPath[$class][$absPath])) {
         // Return it from memory if we already have it
         return $this->objectsByPath[$class][$absPath];
     }
     // do this even if we have item in cache, will throw error if path is deleted - sanity check
     $fetchPath = $this->getFetchPath($absPath, $class);
     if (!$object) {
         // this is the first request, get data from transport
         $object = $this->transport->getNode($fetchPath);
     }
     // recursively create nodes for pre-fetched children if fetchDepth was > 1
     foreach ($object as $name => $properties) {
         if (is_object($properties)) {
             $objVars = get_object_vars($properties);
             $countObjVars = count($objVars);
             // if there's more than one objectvar or just one and this isn't jcr:uuid,
             // then we assume this child was pre-fetched from the backend completely
             if ($countObjVars > 1 || $countObjVars == 1 && !isset($objVars['jcr:uuid'])) {
                 try {
                     $parentPath = '/' === $absPath ? '/' : $absPath . '/';
                     $this->getNodeByPath($parentPath . $name, $class, $properties);
                 } catch (ItemNotFoundException $ignore) {
                     // we get here if the item was deleted or moved locally. just ignore
                 }
             }
         }
     }
     /** @var $node NodeInterface */
     $node = $this->factory->get($class, array($object, $absPath, $this->session, $this));
     if ($uuid = $node->getIdentifier()) {
         // map even nodes that are not mix:referenceable, as long as they have a uuid
         $this->objectsByUuid[$uuid] = $absPath;
     }
     $this->objectsByPath[$class][$absPath] = $node;
     return $this->objectsByPath[$class][$absPath];
 }