You are here

protected function BaseParser::getContext in Markdown 8.2

Builds context around a markdown parser's hierarchy filter format chain.

Parameters

array $context: Additional context to pass.

Return value

array The context, including references to various parser and filter instances.

1 call to BaseParser::getContext()
BaseParser::parse in src/Plugin/Markdown/BaseParser.php
Parses markdown into HTML.

File

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

Class

BaseParser
Base class form Markdown Parser instances.

Namespace

Drupal\markdown\Plugin\Markdown

Code

protected function getContext(array $context = []) {
  $parser = NULL;
  if ($this instanceof ParserAwareInterface) {
    $parser = $this
      ->getParser();
  }
  elseif ($this instanceof ParserInterface) {
    $parser = $this;
  }
  $filter = NULL;
  if ($this instanceof FilterAwareInterface) {
    $filter = $this
      ->getFilter();
  }
  elseif ($parser instanceof FilterAwareInterface) {
    $filter = $parser
      ->getFilter();
  }
  elseif ($this instanceof FilterInterface) {
    $filter = $this;
  }
  $format = NULL;
  if ($this instanceof FilterFormatAwareInterface) {
    $format = $this
      ->getFilterFormat();
  }
  elseif ($parser instanceof FilterFormatAwareInterface) {
    $format = $parser
      ->getFilterFormat();
  }
  elseif ($filter instanceof FilterFormatAwareInterface) {
    $format = $filter
      ->getFilterFormat();
  }
  elseif ($this instanceof FilterFormat) {
    $format = $this;
  }
  return [
    'parser' => $parser,
    'filter' => $filter,
    'format' => $format,
  ] + $context;
}