Esempio n. 1
0
    /**
     * Traverse a node
     *
     * @param NodeInterface $node
     * @param int           $recurse Max recursion level
     * @param int           $level   Recursion level
     */
    public function traverse(NodeInterface $node, $recurse = -1, $level = 0)
    {
        if ($this->mustVisitNode($node)) {

            // Visit node
            $this->nodeVisitor->setLevel($level);
            $node->accept($this->nodeVisitor);

            // Visit properties
            if ($this->propertyVisitor !== null) {
                foreach ($node->getProperties() as $prop) {
                    if ($this->mustVisitProperty($prop)) {
                        $this->propertyVisitor->setLevel($level);
                        $prop->accept($this->propertyVisitor);
                    }
                }
            }

            // Visit children
            foreach ($node->getNodes() as $child) {
                if ($recurse < 0 || $level < $recurse) {
                    $this->traverse($child, $recurse, $level + 1);
                }
            }
        }
    }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  *
  * @api
  */
 public function accept(ItemVisitorInterface $visitor)
 {
     $this->checkState();
     $visitor->visit($this);
 }
Esempio n. 3
0
 /**
  * Accepts an ItemVisitor, calls visit on it
  *
  * @param \PHPCR\ItemVisitorInterface $visitor The ItemVisitor to be accepted.
  * @throws \PHPCR\RepositoryException if an error occurs.
  * @api
  */
 public function accept(\PHPCR\ItemVisitorInterface $visitor)
 {
     $visitor->visit($this);
 }