You are here

public function AllowedHtmlManager::getExtensionDefinitions in Markdown 8.2

Retrieves definitions supported by parser extensions.

Parameters

\Drupal\markdown\Plugin\Markdown\ParserInterface $parser: A parser.

array $definitions: Optional. Specific definitions to filter, if not provided then all plugins with an "extension" type will be filtered.

\Drupal\Core\Theme\ActiveTheme $activeTheme: Optional. The active them. This is used as an indicator when in "render mode".

Return value

array A filtered list of definitions supported by parser extensions.

1 call to AllowedHtmlManager::getExtensionDefinitions()
AllowedHtmlManager::appliesTo in src/PluginManager/AllowedHtmlManager.php
Retrieves plugins that apply to a parser and active theme.

File

src/PluginManager/AllowedHtmlManager.php, line 219

Class

AllowedHtmlManager
Markdown Allowed HTML Plugin Manager.

Namespace

Drupal\markdown\PluginManager

Code

public function getExtensionDefinitions(ParserInterface $parser, array $definitions = NULL, ActiveTheme $activeTheme = NULL) {

  // Immediately return if parser isn't extensible.
  if (!$parser instanceof ExtensibleParserInterface) {
    return [];
  }
  $definitions = isset($definitions) ? $definitions : $this
    ->getType('extension');

  // Extension only applies to parser when it's supported by it.
  foreach ($definitions as $plugin_id => $definition) {
    $class = static::normalizeClassName($definition
      ->getClass());
    foreach ($parser
      ->extensionInterfaces() as $interface) {
      if (is_subclass_of($class, static::normalizeClassName($interface))) {
        continue 2;
      }
    }
    unset($definitions[$plugin_id]);
  }
  return $definitions;
}