/** * Accept visitor. * * @param IdmlVisitor $visitor * @param int $depth */ public function accept(IdmlVisitor $visitor, $depth = 0) { // Group is also visitable just in case it can have a style. $visitor->visitHyperlink($this, $depth); // The boolean $hyperlinkClosed is set to true if any child is an IdmlBrContent object. // Such an object will cause the producer to terminate this hyperlink and start a new paragraph. $hyperlinkClosed = false; foreach ($this->childrenElements as $child) { $child->accept($visitor, $depth + 1); if (is_a($child, 'IdmlBrContent')) { $hyperlinkClosed = true; } } if (!$hyperlinkClosed) { $visitor->visitHyperlinkEnd($this, $depth); } }