You are here

public function MarkdownParserManager::getFallbackPluginId in Markdown 3.0.x

Gets a fallback id for a missing plugin.

Parameters

string $plugin_id: The ID of the missing requested plugin.

array $configuration: An array of configuration relevant to the plugin instance.

Return value

string The id of an existing plugin to use when the plugin does not exist.

Overrides BaseMarkdownPluginManager::getFallbackPluginId

2 calls to MarkdownParserManager::getFallbackPluginId()
MarkdownParserManager::createInstance in src/MarkdownParserManager.php
MarkdownParserManager::getFilter in src/MarkdownParserManager.php
Retrieves the a filter plugin instance based on passed configuration.

File

src/MarkdownParserManager.php, line 73

Class

MarkdownParserManager

Namespace

Drupal\markdown

Code

public function getFallbackPluginId($plugin_id = NULL, array $configuration = []) {

  // Default to thephpleague/commonmark parser.
  if ($plugin_id === NULL) {
    $plugin_id = 'thephpleague/commonmark';
  }

  // Check if the provided parser is valid.
  $plugin_ids = array_keys($this
    ->getDefinitions());
  if (!in_array($plugin_id, $plugin_ids)) {
    $plugin_id = array_shift($plugin_ids);
  }
  if (!$plugin_id) {
    \Drupal::logger('markdown')
      ->warning($this
      ->t('Unknown MarkdownParser: "@parser".', [
      '@parser' => $plugin_id,
    ]));
    $plugin_id = '_broken';
  }
  return $plugin_id;
}