public function MarkdownExtensionManager::getExtensions in Markdown 3.0.x
Retrieves MarkdownExtension plugins.
Parameters
string $parser: Optional. A specific parser's extensions to retrieve. If not set, all available extensions are returned, regardless of the parser.
bool $enabled: Flag indicating whether to filter results based on enabled status. By default, all extensions are returned. If set to TRUE, only enabled extensions are returned. If set to FALSE, only disabled extensions are returned.
Return value
\Drupal\markdown\Plugin\Markdown\Extension\MarkdownExtensionInterface[] An array of MarkdownExtension plugins.
Overrides MarkdownExtensionManagerInterface::getExtensions
File
- src/
MarkdownExtensionManager.php, line 59
Class
Namespace
Drupal\markdownCode
public function getExtensions($parser = NULL, $enabled = NULL) {
// Normalize parser to a string representation of its plugin identifier.
if ($parser instanceof MarkdownParserInterface) {
$parser = $parser
->getPluginId();
}
$extensions = [];
foreach ($this
->getDefinitions() as $plugin_id => $definition) {
// Skip extensions that don't belong to a particular parser.
if ($plugin_id === $this
->getFallbackPluginId() || isset($parser) && $definition['parsers'] && !in_array($parser, $definition['parsers'], TRUE)) {
continue;
}
try {
$extension = $this
->createInstance($plugin_id);
// Set settings from the definition (i.e. added via alter).
if (isset($definition['settings'])) {
$extension
->setSettings($definition['settings']);
}
if ($enabled === TRUE && $extension
->isEnabled()) {
$extensions[$plugin_id] = $extension;
}
elseif ($enabled === FALSE && !$extension
->isEnabled()) {
$extensions[$plugin_id] = $extension;
}
elseif ($enabled === NULL) {
$extensions[$plugin_id] = $extension;
}
} catch (PluginException $e) {
// Intentionally left empty.
}
}
return $extensions;
}