/** * Defines method to accept {@link Visitors}. * * Imlements {@link http://en.wikipedia.org/wiki/Visitor_pattern Visitor Pattern}. * * @param Visitor $visitor Object which visits te node. * * @return void */ public function accept(Visitor $visitor) { $visitor->beforeVisit($this); $visitor->visit($this); $visitor->afterVisit($this); }
/** * Defines method to accept {@link Visitors}. * * Imlements {@link http://en.wikipedia.org/wiki/Visitor_pattern Visitor Pattern}. * * @param Visitor $visitor Object which visits te node. * * @return void */ public function accept(Visitor $visitor) { $visitor->beforeVisit($this); $visitor->visit($this); if ($this->hasChildren()) { foreach ($this->getIterator() as $subnode) { $subnode->accept($visitor); } } $visitor->afterVisit($this); }