You are here

public function MarkdownParserManager::createInstance in Markdown 3.0.x

Return value

\Drupal\markdown\Plugin\Markdown\MarkdownParserInterface A MarkdownParser plugin.

Overrides PluginManagerBase::createInstance

1 call to MarkdownParserManager::createInstance()
MarkdownParserManager::getParser in src/MarkdownParserManager.php
Retrieves a parser based on a filter and its settings.

File

src/MarkdownParserManager.php, line 55

Class

MarkdownParserManager

Namespace

Drupal\markdown

Code

public function createInstance($plugin_id = NULL, array $configuration = []) {
  $plugin_id = $this
    ->getFallbackPluginId($plugin_id, $configuration);

  // Retrieve the filter from the configuration.
  $filter = $this
    ->getFilter($plugin_id, $configuration);

  // Set the settings.
  $configuration['settings'] = NestedArray::mergeDeep($this->settings
    ->get($plugin_id) ?: [], $filter ? $filter
    ->getParserSettings() : []);

  /** @var \Drupal\markdown\Plugin\Markdown\MarkdownParserInterface $parser */
  $parser = parent::createInstance($plugin_id, $configuration);
  return $parser;
}