You are here

public function BaseParser::loadUrl in Markdown 3.0.x

Loads a cached ParsedMarkdown object for a URL.

Parameters

string $id: A unique identifier that will be used to cache the parsed markdown.

string $url: The external URL of a markdown file to parse if the cached ParsedMarkdown object doesn't yet exist. Once parsed, its identifier will be set to the provided $id and then cached.

\Drupal\Core\Language\LanguageInterface $language: Optional. The language of the markdown that is being parsed.

Return value

\Drupal\markdown\ParsedMarkdownInterface A ParsedMarkdown object.

Throws

\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException When the provided $url does not exist or is not reachable.

Overrides MarkdownParserInterface::loadUrl

File

src/Plugin/Markdown/BaseParser.php, line 402

Class

BaseParser
Plugin annotation @MarkdownParser( id = "_broken", label = @Translation("Missing Parser"), )

Namespace

Drupal\markdown\Plugin\Markdown

Code

public function loadUrl($id, $url, LanguageInterface $language = NULL) {
  return ParsedMarkdown::load($id) ?: $this
    ->parseUrl($url, $language)
    ->setId($id)
    ->save();
}