Пример #1
0
 public function handle(Document $document)
 {
     if (false === $this->hasContent()) {
         return;
         // prevents ErrorException in Html.php line 42: DOMDocument::loadHTMLFile(): Empty string supplied as input
     }
     $d = $document->getDom();
     $d->find('//a')->each(function (Element $element) {
         $url = $element->getAttribute('href');
         try {
             if ($this->isAction($url)) {
                 $this->callAction($element);
             } elseif ($this->isDocument($url) && $this->isRelative($url)) {
                 // replaces links that reference other documents to the right url
                 $element->setAttribute('href', $this->getDocumentUrl($url));
             }
         } catch (InvalidArgumentException $e) {
             $this->codex->log('debug', static::class . " throws exception: {$e->getMessage()} | file: {$e->getFile()} | line: {$e->getLine()} | trace: {$e->getTraceAsString()}");
         }
     });
     $document->setDom($d);
 }