abstract class BaseExtensibleParser in Markdown 8.2
Base class for extensible markdown parsers.
@property \Drupal\markdown\Annotation\MarkdownParser $pluginDefinition @method \Drupal\markdown\Annotation\MarkdownParser getPluginDefinition()
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\markdown\Plugin\Markdown\AnnotatedPluginBase implements AnnotatedPluginInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\markdown\Plugin\Markdown\InstallablePluginBase implements InstallablePluginInterface uses PluginDependencyTrait, MoreInfoTrait
- class \Drupal\markdown\Plugin\Markdown\BaseParser implements PluginFormInterface, ParserInterface, FilterAwareInterface uses RefinableCacheableDependencyTrait, EnabledPluginTrait, FilterAwareTrait, SettingsTrait
- class \Drupal\markdown\Plugin\Markdown\BaseExtensibleParser implements ExtensibleParserInterface
- class \Drupal\markdown\Plugin\Markdown\BaseParser implements PluginFormInterface, ParserInterface, FilterAwareInterface uses RefinableCacheableDependencyTrait, EnabledPluginTrait, FilterAwareTrait, SettingsTrait
- class \Drupal\markdown\Plugin\Markdown\InstallablePluginBase implements InstallablePluginInterface uses PluginDependencyTrait, MoreInfoTrait
- class \Drupal\markdown\Plugin\Markdown\AnnotatedPluginBase implements AnnotatedPluginInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of BaseExtensibleParser
1 file declares its use of BaseExtensibleParser
- CommonMark.php in src/
Plugin/ Markdown/ CommonMark/ CommonMark.php
File
- src/
Plugin/ Markdown/ BaseExtensibleParser.php, line 16
Namespace
Drupal\markdown\Plugin\MarkdownView source
abstract class BaseExtensibleParser extends BaseParser implements ExtensibleParserInterface {
/**
* The extension configuration.
*
* @var array
*/
protected $extensions = [];
/**
* A collection of MarkdownExtension plugins specific to the parser.
*
* @var \Drupal\markdown\PluginManager\ExtensionCollection
*/
protected $extensionCollection;
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'extensions' => [],
] + parent::defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function extension($extensionId) {
return $this
->extensions()
->get($extensionId);
}
/**
* {@inheritdoc}
*/
public function extensionInterfaces() {
return isset($this->pluginDefinition['extensionInterfaces']) ? $this->pluginDefinition['extensionInterfaces'] : [];
}
/**
* {@inheritdoc}
*/
public function extensions() {
if (!isset($this->extensionCollection)) {
$this->extensionCollection = new ExtensionCollection($this
->getContainer()
->get('plugin.manager.markdown.extension'), $this);
}
return $this->extensionCollection;
}
/**
* {@inheritdoc}
*/
public function getBundledExtensionIds() {
return isset($this->pluginDefinition['bundledExtensions']) ? $this->pluginDefinition['bundledExtensions'] : [];
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
$configuration = parent::getConfiguration();
// Normalize extensions and their settings.
$extensions = [];
$extensionCollection = $this
->extensions();
/** @var \Drupal\markdown\Plugin\Markdown\ExtensionInterface $extension */
foreach ($extensionCollection as $extensionId => $extension) {
// Only include extensions that have configuration overrides.
if ($overrides = $extension
->getConfigurationOverrides()) {
$extensionConfiguration = $extension
->getSortedConfiguration();
// This is part of the parser config, the extension dependencies
// aren't needed as they're determined and merged elsewhere.
unset($extensionConfiguration['dependencies']);
$extensions[] = $extensionConfiguration;
}
}
// Sort extensions so they're always in the same order.
uasort($extensions, function ($a, $b) {
return SortArray::sortByKeyString($a, $b, 'id');
});
// Don't use an associative array, just an indexed list of extensions.
$configuration['extensions'] = array_values($extensions);
return $configuration;
}
/**
* {@inheritdoc}
*/
protected function getConfigurationSortOrder() {
return [
'extensions' => 100,
] + parent::getConfigurationSortOrder();
}
/**
* Indicates whether an extension is "required" by another extension.
*
* @param \Drupal\markdown\Plugin\Markdown\ExtensionInterface $extension
* The extension to check.
*
* @return bool
* TRUE or FALSE
*/
protected function isExtensionRequired(ExtensionInterface $extension) {
// Check whether extension is required by another enabled extension.
if ($requiredBy = $extension
->requiredBy()) {
foreach ($requiredBy as $dependent) {
if ($this
->extension($dependent)
->isEnabled()) {
return TRUE;
}
}
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getPluginCollections() {
return [
'extensions' => $this
->extensions(),
];
}
/**
* {@inheritdoc}
*/
protected function getPluginDependencies(PluginInspectionInterface $instance) {
// Only include extensions that are enabled or required.
if (!$instance instanceof ExtensionInterface || ($instance
->isEnabled() || $this
->isExtensionRequired($instance))) {
return parent::getPluginDependencies($instance);
}
return [];
}
/**
* Sets the configuration for an extension plugin instance.
*
* @param string $extensionId
* The identifier of the extension plugin to set the configuration for.
* @param array $configuration
* The extension plugin configuration to set.
*
* @return static
*
* @todo Actually use this.
*/
public function setExtensionConfig($extensionId, array $configuration) {
$this->extensions[$extensionId] = $configuration;
if (isset($this->extensionCollection)) {
$this->extensionCollection
->setInstanceConfiguration($extensionId, $configuration);
}
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AnnotatedPluginBase:: |
protected | property | The original plugin_id that was called, not a fallback identifier. | |
AnnotatedPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Retrieves the configuration overrides for the plugin. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Retrieves the description of the plugin, if set. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Retrieves the original plugin identifier. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Returns the provider (extension name) of the plugin. Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Returns the weight of the plugin (used for sorting). Overrides AnnotatedPluginInterface:: |
|
AnnotatedPluginBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
AnnotatedPluginBase:: |
public | function | ||
BaseExtensibleParser:: |
protected | property | A collection of MarkdownExtension plugins specific to the parser. | |
BaseExtensibleParser:: |
protected | property | The extension configuration. | |
BaseExtensibleParser:: |
public | function |
Gets default configuration for this plugin. Overrides InstallablePluginBase:: |
|
BaseExtensibleParser:: |
public | function |
Retrieves a specific extension plugin instance. Overrides ExtensibleParserInterface:: |
|
BaseExtensibleParser:: |
public | function |
An array of extension interfaces that the parser supports. Overrides ExtensibleParserInterface:: |
1 |
BaseExtensibleParser:: |
public | function |
Returns the ordered collection of extension plugin instances. Overrides ExtensibleParserInterface:: |
|
BaseExtensibleParser:: |
public | function |
Retrieves plugin identifiers of extensions bundled with the parser. Overrides ExtensibleParserInterface:: |
|
BaseExtensibleParser:: |
public | function |
Gets this plugin's configuration. Overrides BaseParser:: |
1 |
BaseExtensibleParser:: |
protected | function |
Determines the configuration sort order by weight. Overrides BaseParser:: |
|
BaseExtensibleParser:: |
public | function |
Gets the plugin collections used by this object. Overrides ObjectWithPluginCollectionInterface:: |
|
BaseExtensibleParser:: |
protected | function |
Overrides InstallablePluginBase:: |
|
BaseExtensibleParser:: |
protected | function | Indicates whether an extension is "required" by another extension. | |
BaseExtensibleParser:: |
public | function | Sets the configuration for an extension plugin instance. | |
BaseParser:: |
protected | property | ||
BaseParser:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
3 |
BaseParser:: |
abstract protected | function | Converts Markdown into HTML. | 4 |
BaseParser:: |
public | function |
Overrides RenderStrategyInterface:: |
|
BaseParser:: |
public | function |
Retrieves the allowed HTML plugins relevant to the object. Overrides RenderStrategyInterface:: |
|
BaseParser:: |
protected | function | Builds context around a markdown parser's hierarchy filter format chain. | |
BaseParser:: |
public | function |
Retrieves the custom (user provided) allowed HTML. Overrides RenderStrategyInterface:: |
|
BaseParser:: |
public | function |
Retrieves the render strategy to use. Overrides RenderStrategyInterface:: |
|
BaseParser:: |
public | function |
Parses markdown into HTML. Overrides ParserInterface:: |
|
BaseParser:: |
protected | function | A description explaining why a setting is disabled due to render strategy. | |
BaseParser:: |
protected | function | Adds a conditional state for a setting element based on render strategy. | |
BaseParser:: |
public static | function | Validates parser settings. | |
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
public | function | 3 | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. | |
EnabledPluginTrait:: |
public | function | 1 | |
EnabledPluginTrait:: |
public | function | ||
FilterAwareTrait:: |
protected | property | A Filter plugin. | |
FilterAwareTrait:: |
public | function | ||
FilterAwareTrait:: |
public | function | ||
InstallablePluginBase:: |
protected | property | The config for this plugin. | |
InstallablePluginBase:: |
public | function |
Builds a display for a library. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Builds a display status based on the current state of the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the config instance for this plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
protected static | function | ||
InstallablePluginBase:: |
public | function | Retrieves available installs. | |
InstallablePluginBase:: |
protected | function | Returns the configuration name for the plugin. | |
InstallablePluginBase:: |
public | function | Retrieves the container. | |
InstallablePluginBase:: |
public | function |
Retrieves the deprecation message, if any. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the experimental message. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the composer package name of the installable library, if any. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the installed library used by the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Displays the human-readable label of the plugin. Overrides AnnotatedPluginBase:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the plugin as a link using its label and URL. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
@TODO: Refactor to use variadic parameters. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the class name of the object defined by the installed library. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the preferred library of the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the configuration for the plugin, but sorted. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Retrieves the URL of the plugin, if set. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
The current version of the plugin. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function | ||
InstallablePluginBase:: |
public | function |
Indicates whether plugin has multiple installs to check. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Indicates whether the plugin is installed. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Indicates whether the plugin is using the preferred library. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Indicates whether the preferred library is installed. Overrides InstallablePluginInterface:: |
|
InstallablePluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides AnnotatedPluginBase:: |
3 |
InstallablePluginBase:: |
public | function |
Indicates whether the plugin should be shown in the UI. Overrides InstallablePluginInterface:: |
|
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MoreInfoTrait:: |
protected | function | Appends existing content with a "More Info" link. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | |
PluginDependencyTrait:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. Aliased as: getPluginDependenciesTrait | |
PluginDependencyTrait:: |
protected | function | Wraps the module handler. | |
PluginDependencyTrait:: |
protected | function | Wraps the theme handler. | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RendererTrait:: |
protected static | property | The Renderer service. | |
RendererTrait:: |
protected | function | Retrieves the Renderer service. | |
RenderStrategyInterface:: |
constant | The documentation URL for further explaining render strategies. | ||
RenderStrategyInterface:: |
constant | Strategy used to escape HTML input prior to parsing markdown. | ||
RenderStrategyInterface:: |
constant | Strategy used to filter the output of parsed markdown. | ||
RenderStrategyInterface:: |
constant | The URL for explaining Markdown and XSS; render strategies. | ||
RenderStrategyInterface:: |
constant | No render strategy. | ||
RenderStrategyInterface:: |
constant | Strategy used to remove HTML input prior to parsing markdown. | ||
SettingsTrait:: |
protected | function | Creates a setting element. | |
SettingsTrait:: |
public static | function | 9 | |
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | 2 | |
SettingsTrait:: |
public | function | 6 | |
SettingsTrait:: |
public | function | ||
SettingsTrait:: |
public | function | 2 | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |