/** * @return string */ public function getPath() { if ($this->path === null) { if ($this->parent === null || $this->parent->getPath() === null) { $this->path = $this->name; } else { $this->path = $this->parent->getPath() . '/' . $this->name; } } return $this->path; }
public function getPath(&$prevNodes = []) { if ($this->_parent) { array_push($prevNodes, $this); $this->_parent->getPath($prevNodes); } return $prevNodes; }
/** * * @dataProvider testConstructFromArrayProvider */ public function testConstructFromArray($testData, $expectedData) { $n = new Node($testData); extract($expectedData); $this->assertEquals($path, $n->getPath()); $this->assertEquals($url, $n->url); $this->assertEquals($template_data, $n->template_data); $this->assertEquals($display_name, $n->display_name); }
private function checkLocks(Node $node) { if ($node->isLocked()) { throw new LockException("cannot move locked node: {$this->workspace}=>" . $node->getPath()); } else { if ($node->hasNodes()) { $ni = $node->getNodes(); while ($ni->hasNext()) { $temporaryNode = $ni->nextNode(); if ($temporaryNode->hasNodes()) { $this->checkLocks($temporaryNode); } else { if ($temporaryNode->isLocked()) { throw new LockException("cannot move locked node: {$this->workspace}=>" . $temporaryNode->getPath()); } } } } } }
/** * Internal recursion for find() * * @param array $ret * @param \USync\AST\NodeInterface[] $node * @param int $depth * * @return \USync\AST\NodeInterface[] */ protected function _find(&$ret, Node $node, $depth = 0) { $current = $this->segments[$depth]; if (self::MATCH === $current[0] || self::WILDCARD === $current || $node->getName() === $current) { if ($depth === $this->size) { $ret[$node->getPath()] = $node; } else { foreach ($node->getChildren() as $child) { $this->_find($ret, $child, $depth + 1); } } } }
/** * * Retrieves an existing persistent query. * If node is not a valid persisted query, an InvalidQueryException is thrown. * Persistent queries are created by first using QueryManager->createQuery to create a Query object and then calling Query->storeAsNode to persist the query to a location in the workspace. * @param Node $node a persisted query. * @return Query a Query object. * */ public function getQuery(Node $node) { Log4PCR::info("Requested query: {$this->workspace}=>" . $node->getPath()); return new Query($this->pm, $node->getProperty('pcr:statement')->getString()); }