/** * @param int $lineNumber * * @return BlockInterface|mixed|null|string */ protected function grabReferences($lineNumber) { $content = $this->dataObject->getLine($lineNumber); // grab urls with title $content = preg_replace_callback('/\\[(.*)\\]:\\s?(.*)\\s?"(.*)"/U', function ($found) { $key = trim($found[1]); $url = trim($found[2]); $title = trim($found[3]); $this->dataObject->addReference($key, ['url' => $url, 'title' => $title, 'type' => 'url']); return ''; }, $content); // grab urls without title $content = preg_replace_callback('/\\[(.*)\\]:\\s?(.*)/', function ($found) { $key = trim($found[1]); $url = trim($found[2]); $this->dataObject->addReference($key, ['url' => $url, 'title' => '', 'type' => 'url']); return ''; }, $content); return $content; }
/** * @param DataObjectInterface $dataObject * @param int $lineNumber */ protected function createSkipLine(DataObjectInterface $dataObject, $lineNumber) { $lineContent = $dataObject->getLine($lineNumber); $changedContent = $this->factory->create(BlockTypes::BLOCK_SKIP); $changedContent->setContent($lineContent->getContent()); $dataObject->updateLine($lineNumber, $changedContent); }