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];
}