Jackalope\Transport\DoctrineDBAL\Client::getNodes PHP 메소드

getNodes() 공개 메소드

{@inheritDoc}
public getNodes ( $paths )
    public function getNodes($paths)
    {
        $this->assertLoggedIn();
        if (empty($paths)) {
            return array();
        }
        foreach ($paths as $path) {
            PathHelper::assertValidAbsolutePath($path, false, true, $this->getNamespacePrefixes());
        }
        $params[':workspace'] = $this->workspaceName;
        if ($this->fetchDepth > 0) {
            $params[':fetchDepth'] = $this->fetchDepth;
            $query = '
              SELECT path AS arraykey, id, path, parent, local_name, namespace, workspace_name, identifier, type, props, depth, sort_order
              FROM phpcr_nodes
              WHERE workspace_name = :workspace
                AND (';
            $i = 0;
            foreach ($paths as $path) {
                $params[':path' . $i] = $path;
                $params[':pathd' . $i] = rtrim($path, '/') . '/%';
                $subquery = 'SELECT depth FROM phpcr_nodes WHERE path = :path' . $i . ' AND workspace_name = :workspace';
                $query .= '(path LIKE :pathd' . $i . ' OR path = :path' . $i . ') AND depth <= ((' . $subquery . ') + :fetchDepth) OR ';
                $i++;
            }
        } else {
            $query = 'SELECT path AS arraykey, id, path, parent, local_name, namespace, workspace_name, identifier, type, props, depth, sort_order
                FROM phpcr_nodes WHERE workspace_name = :workspace AND (';
            $i = 0;
            foreach ($paths as $path) {
                $params[':path' . $i] = $path;
                $query .= 'path = :path' . $i . ' OR ';
                $i++;
            }
        }
        $query = rtrim($query, 'OR ');
        $query .= ') ORDER BY sort_order ASC';
        $stmt = $this->getConnection()->executeQuery($query, $params);
        $all = $stmt->fetchAll(\PDO::FETCH_UNIQUE | \PDO::FETCH_GROUP);
        $nodes = array();
        if ($all) {
            $nodes = $this->getNodesData($all);
        }
        return $nodes;
    }

Usage Example

 /**
  * {@inheritDoc}
  */
 public function getNodes($paths)
 {
     if (empty($this->caches['nodes'])) {
         return parent::getNodes($paths);
     }
     $nodes = array();
     foreach ($paths as $key => $path) {
         try {
             $nodes[$key] = $this->getNode($path);
         } catch (\PHPCR\ItemNotFoundException $e) {
             // ignore
         }
     }
     return $nodes;
 }