/** * as defined by interface: do something with this item. * we expect a node, will throw an exception if anything else */ public function visit(ItemInterface $item) { if (!$item instanceof NodeInterface) { throw new \Exception("Internal error: did not expect to visit a non-node object: {$item}"); } $document = $this->odm->find(null, $item->getPath()); if (!$this->showall && !$document->getVisible()) { // ignore hidden entries return; } $url = $this->getUrl($document); $this->tree[$url] = $document->getLabel(); //TODO: this could return the same list of info as menucollectorvisitor, making that one obsolete }
/** * Print information about the visited node. * * @param ItemInterface $item the node to visit */ public function visit(ItemInterface $item) { if (!$item instanceof NodeInterface) { throw new \Exception("Internal error: did not expect to visit a non-node object: {$item}"); } if ($item->getDepth() == 0) { $name = 'ROOT'; } elseif ($this->showFullPath) { $name = $item->getPath(); } else { $name = $item->getName(); } $out = str_repeat(' ', $this->level) . '<comment>' . $name . '</comment>'; if ($this->identifiers) { $identifier = $item->getIdentifier(); if ($identifier) { $out .= "({$identifier})"; } } $out .= ':'; $this->output->writeln($out); }