Jackalope\Transport\DoctrineDBAL\Client::getNode PHP Méthode

getNode() public méthode

{@inheritDoc}
public getNode ( $path )
    public function getNode($path)
    {
        $this->assertLoggedIn();
        PathHelper::assertValidAbsolutePath($path, false, true, $this->getNamespacePrefixes());
        $values[':path'] = $path;
        $values[':pathd'] = rtrim($path, '/') . '/%';
        $values[':workspace'] = $this->workspaceName;
        if ($this->fetchDepth > 0) {
            $values[':fetchDepth'] = $this->fetchDepth;
            $query = '
              SELECT * FROM phpcr_nodes
              WHERE (path LIKE :pathd OR path = :path)
                AND workspace_name = :workspace
                AND depth <= ((SELECT depth FROM phpcr_nodes WHERE path = :path AND workspace_name = :workspace) + :fetchDepth)
              ORDER BY depth, sort_order ASC';
        } else {
            $query = '
              SELECT * FROM phpcr_nodes
              WHERE path = :path
                AND workspace_name = :workspace
              ORDER BY depth, sort_order ASC';
        }
        $stmt = $this->getConnection()->executeQuery($query, $values);
        $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
        if (empty($rows)) {
            throw new ItemNotFoundException("Item {$path} not found in workspace " . $this->workspaceName);
        }
        $nestedNodes = $this->getNodesData($rows);
        $node = array_shift($nestedNodes);
        foreach ($nestedNodes as $nestedPath => $nested) {
            $relativePath = PathHelper::relativizePath($nestedPath, $path);
            $this->nestNode($node, $nested, explode('/', $relativePath));
        }
        return $node;
    }

Usage Example

 /**
  * {@inheritDoc}
  */
 public function getNode($path)
 {
     if (empty($this->caches['nodes'])) {
         return parent::getNode($path);
     }
     $this->assertLoggedIn();
     $cacheKey = "nodes: {$path}, " . $this->workspaceName;
     $cacheKey = $this->sanitizeKey($cacheKey);
     if (false !== ($result = $this->caches['nodes']->fetch($cacheKey))) {
         if ('ItemNotFoundException' === $result) {
             throw new ItemNotFoundException(sprintf('Item "%s" not found in workspace "%s"', $path, $this->workspaceName));
         }
         return $result;
     }
     try {
         $node = parent::getNode($path);
     } catch (ItemNotFoundException $e) {
         if (isset($this->caches['nodes'])) {
             $this->caches['nodes']->save($cacheKey, 'ItemNotFoundException');
         }
         throw $e;
     }
     $this->caches['nodes']->save($cacheKey, $node);
     return $node;
 }
All Usage Examples Of Jackalope\Transport\DoctrineDBAL\Client::getNode