class ParserManager in Markdown 8.2
Markdown Parser Plugin Manager.
@method \Drupal\markdown\Plugin\Markdown\ParserInterface[] all(array $configuration = [], $includeFallback = FALSE) : array @method \Drupal\markdown\Plugin\Markdown\ParserInterface[] enabled(array $configuration = []) : array @method \Drupal\markdown\Annotation\MarkdownParser getDefinition($plugin_id, $exception_on_invalid = TRUE) @method \Drupal\markdown\Annotation\MarkdownParser|void getDefinitionByClassName($className) @method \Drupal\markdown\Annotation\MarkdownParser[] getDefinitions($includeFallback = TRUE) @method \Drupal\markdown\Plugin\Markdown\ParserInterface[] installed(array $configuration = []) : array @noinspection PhpUnnecessaryFullyQualifiedNameInspection
Hierarchy
- class \Drupal\Component\Plugin\PluginManagerBase implements PluginManagerInterface uses DiscoveryTrait
- class \Drupal\Core\Plugin\DefaultPluginManager implements CachedDiscoveryInterface, PluginManagerInterface, CacheableDependencyInterface uses DiscoveryCachedTrait, UseCacheBackendTrait
- class \Drupal\markdown\PluginManager\InstallablePluginManager implements InstallablePluginManagerInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait, StringTranslationTrait, NormalizeTrait
- class \Drupal\markdown\PluginManager\ParserManager implements ParserManagerInterface uses EnableAwarePluginManagerTrait
- class \Drupal\markdown\PluginManager\InstallablePluginManager implements InstallablePluginManagerInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait, StringTranslationTrait, NormalizeTrait
- class \Drupal\Core\Plugin\DefaultPluginManager implements CachedDiscoveryInterface, PluginManagerInterface, CacheableDependencyInterface uses DiscoveryCachedTrait, UseCacheBackendTrait
Expanded class hierarchy of ParserManager
4 files declare their use of ParserManager
- BaseParser.php in src/
Plugin/ Markdown/ BaseParser.php - InstallableRequirement.php in src/
Annotation/ InstallableRequirement.php - markdown.install in ./
markdown.install - Install, update and uninstall functions for the markdown module.
- markdown.post_update.php in ./
markdown.post_update.php - Markdown post updates.
1 string reference to 'ParserManager'
1 service uses ParserManager
File
- src/
PluginManager/ ParserManager.php, line 28
Namespace
Drupal\markdown\PluginManagerView source
class ParserManager extends InstallablePluginManager implements ParserManagerInterface {
use EnableAwarePluginManagerTrait;
/**
* {@inheritdoc}
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ConfigFactoryInterface $configFactory, LoggerInterface $logger, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/Markdown', $namespaces, $configFactory, $logger, $module_handler, ParserInterface::class, MarkdownParser::class);
$this
->setCacheBackend($cache_backend, 'markdown_parser_info');
$this
->alterInfo($this->cacheKey);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container = NULL) {
if (!$container) {
$container = \Drupal::getContainer();
}
$instance = new static($container
->get('container.namespaces'), $container
->get('cache.discovery'), $container
->get('config.factory'), $container
->get('logger.channel.markdown'), $container
->get('module_handler'));
$instance
->setContainer($container);
return $instance;
}
/**
* {@inheritdoc}
*
* @return \Drupal\markdown\Plugin\Markdown\ParserInterface
* A Parser instance.
*/
public function createInstance($plugin_id, array $configuration = []) {
/** @var \Drupal\markdown\Plugin\Markdown\ParserInterface $parser */
$parser = parent::createInstance($plugin_id, $configuration);
// If the parser is the fallback parser (missing), then just return it.
if ($parser
->getPluginId() === $this
->getFallbackPluginId()) {
return $parser;
}
// Add a default cache tag.
$parser
->addCacheTags([
"markdown.parser.{$plugin_id}",
]);
return $parser;
}
/**
* {@inheritDoc}
*/
public function getDefaultParser(array $configuration = []) {
$settings = $this->configFactory
->get('markdown.settings');
if (!($defaultParser = $settings
->get('default_parser'))) {
$defaultParser = current(array_keys($this
->installed()));
$this->logger
->warning($this
->t('No default markdown parser set, using first available installed parser "@default_parser".', [
'@default_parser' => $defaultParser,
]));
}
return $this
->createInstance($defaultParser, $configuration);
}
/**
* {@inheritdoc}
*/
public function getFallbackPluginId($plugin_id = NULL, array $configuration = []) {
return '_missing_parser';
}
/**
* {@inheritdoc}
*/
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
if (!$definition instanceof MarkdownParser || !$definition
->isInstalled() || !($class = $definition
->getClass())) {
return;
}
// Process extensible parser support.
if (is_subclass_of($class, ExtensibleParserInterface::class)) {
if (!$definition->extensionInterfaces) {
throw new InvalidPluginDefinitionException($plugin_id, sprintf('Markdown parser "%s" implements %s but is missing "extensionInterfaces" in the definition.', $plugin_id, ExtensibleParserInterface::class));
}
foreach (array_map('\\Drupal\\markdown\\PluginManager\\InstallablePluginManager::normalizeClassName', $definition->extensionInterfaces) as $interface) {
if ($interface === ExtensionInterface::class) {
throw new InvalidPluginDefinitionException($plugin_id, sprintf('Markdown parser "%s" cannot specify %s as the extension interface. It must create its own unique interface that extend from it.', $plugin_id, ExtensionInterface::class));
}
if (!interface_exists($interface)) {
throw new InvalidPluginDefinitionException($plugin_id, sprintf('Markdown parser "%s" indicates that it supports the extension interface "%s", but this interface does not exist.', $plugin_id, $interface));
}
if (!is_subclass_of($interface, ExtensionInterface::class)) {
throw new InvalidPluginDefinitionException($plugin_id, sprintf('Markdown parser "%s" indicates that it supports the extension interface "%s", but this interface does not extend %s.', $plugin_id, $interface, ExtensionInterface::class));
}
}
}
}
/**
* {@inheritdoc}
*/
protected function providerExists($provider) {
// It's known that plugins provided by this module exist. Explicitly and
// always return TRUE for this case. This is needed during install when
// the module is not yet (officially) installed.
// @see markdown_requirements()
if ($provider === 'markdown') {
return TRUE;
}
return parent::providerExists($provider);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultPluginManager:: |
protected | property | Additional namespaces the annotation discovery mechanism should scan for annotation definitions. | |
DefaultPluginManager:: |
protected | property | Name of the alter hook if one should be invoked. | |
DefaultPluginManager:: |
protected | property | The cache key. | |
DefaultPluginManager:: |
protected | property | An array of cache tags to use for the cached definitions. | |
DefaultPluginManager:: |
protected | property | A set of defaults to be referenced by $this->processDefinition() if additional processing of plugins is necessary or helpful for development purposes. | 9 |
DefaultPluginManager:: |
protected | property | The module handler to invoke the alter hook. | 1 |
DefaultPluginManager:: |
protected | property | An object that implements \Traversable which contains the root paths keyed by the corresponding namespace to look for plugin implementations. | |
DefaultPluginManager:: |
protected | property | The name of the annotation that contains the plugin definition. | |
DefaultPluginManager:: |
protected | property | The interface each plugin should implement. | 1 |
DefaultPluginManager:: |
protected | property | The subdirectory within a namespace to look for plugins, or FALSE if the plugins are in the top level of the namespace. | |
DefaultPluginManager:: |
protected | function | Sets the alter hook name. | |
DefaultPluginManager:: |
protected | function | Extracts the provider from a plugin definition. | |
DefaultPluginManager:: |
private | function | Fix the definitions of context-aware plugins. | |
DefaultPluginManager:: |
protected | function |
Gets the plugin discovery. Overrides PluginManagerBase:: |
12 |
DefaultPluginManager:: |
protected | function |
Gets the plugin factory. Overrides PluginManagerBase:: |
|
DefaultPluginManager:: |
public | function |
Disable the use of caches. Overrides CachedDiscoveryInterface:: |
1 |
DiscoveryCachedTrait:: |
protected | property | Cached definitions array. | 1 |
DiscoveryCachedTrait:: |
public | function |
Overrides DiscoveryTrait:: |
3 |
DiscoveryTrait:: |
protected | function | Gets a specific plugin definition. | |
DiscoveryTrait:: |
public | function | ||
EnableAwarePluginManagerTrait:: |
public | function | ||
InstallablePluginManager:: |
protected | property | Cache contexts. | |
InstallablePluginManager:: |
protected | property | Cache max-age. | |
InstallablePluginManager:: |
protected | property | The Config Factory service. | |
InstallablePluginManager:: |
protected | property | A Logger service. | |
InstallablePluginManager:: |
protected static | property | The cached runtime definitions. | |
InstallablePluginManager:: |
public | function |
Retrieves all registered plugins. Overrides InstallablePluginManagerInterface:: |
|
InstallablePluginManager:: |
protected | function | Allows plugin managers to further alter individual definitions. | 2 |
InstallablePluginManager:: |
protected | function |
Invokes the hook to alter the definitions if the alter hook is set. Overrides DefaultPluginManager:: |
2 |
InstallablePluginManager:: |
public | function |
Clears static and persistent plugin definition caches. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
protected | function | Converts plugin definitions using the old "installed" method to libraries. | |
InstallablePluginManager:: |
protected | function | 1 | |
InstallablePluginManager:: |
protected | function |
Finds plugin definitions. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
public | function |
Retrieves the first installed plugin identifier. Overrides InstallablePluginManagerInterface:: |
|
InstallablePluginManager:: |
public | function |
The cache contexts associated with this object. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
protected | function |
Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
public | function |
Retrieves the cache key to use. Overrides InstallablePluginManagerInterface:: |
|
InstallablePluginManager:: |
public | function |
The maximum age for which this object may be cached. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
public | function |
The cache tags associated with this object. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
public | function | Retrieves the container. | |
InstallablePluginManager:: |
public | function |
Retrieves a definition by class name. Overrides InstallablePluginManagerInterface:: |
|
InstallablePluginManager:: |
public | function |
Retrieves a definition by library identifier. Overrides InstallablePluginManagerInterface:: |
|
InstallablePluginManager:: |
public | function |
Gets the definition of all plugins for this type. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
protected | function | Retrieves the runtime definitions. | |
InstallablePluginManager:: |
protected | function |
Allows plugin managers to specify custom behavior if a plugin is not found. Overrides PluginManagerBase:: |
|
InstallablePluginManager:: |
public | function |
Retrieves all installed plugins. Overrides InstallablePluginManagerInterface:: |
|
InstallablePluginManager:: |
public | function |
Retrieves installed plugin definitions. Overrides InstallablePluginManagerInterface:: |
|
InstallablePluginManager:: |
protected | function | Processes the library definition. | |
InstallablePluginManager:: |
public | function |
Initialize the cache backend. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
protected | function |
Sets a cache of plugin definitions for the decorated discovery class. Overrides DefaultPluginManager:: |
|
InstallablePluginManager:: |
protected | function | Sorts a definitions array. | |
NormalizeTrait:: |
public static | function | ||
NormalizeTrait:: |
public static | function | Indicates whether a value is traversable. | |
NormalizeTrait:: |
public static | function | Normalizes any callables provided so they can be stored in the database. | |
NormalizeTrait:: |
public static | function | Normalizes class names to prevent double escaping. | |
ParserManager:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
ParserManager:: |
public | function |
Overrides InstallablePluginManager:: |
|
ParserManager:: |
public | function |
Retrieves the site-wide default MarkdownParser plugin. Overrides ParserManagerInterface:: |
|
ParserManager:: |
public | function |
Gets a fallback id for a missing plugin. Overrides InstallablePluginManager:: |
|
ParserManager:: |
public | function |
Performs extra processing on plugin definitions. Overrides InstallablePluginManager:: |
|
ParserManager:: |
protected | function |
Determines if the provider of a definition exists. Overrides DefaultPluginManager:: |
|
ParserManager:: |
public | function |
Creates the discovery object. Overrides InstallablePluginManager:: |
|
PluginManagerBase:: |
protected | property | The object that discovers plugins managed by this manager. | |
PluginManagerBase:: |
protected | property | The object that instantiates plugins managed by this manager. | |
PluginManagerBase:: |
protected | property | The object that returns the preconfigured plugin instance appropriate for a particular runtime condition. | |
PluginManagerBase:: |
public | function |
Gets a preconfigured instance of a plugin. Overrides MapperInterface:: |
7 |
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. | |
UseCacheBackendTrait:: |
protected | property | Cache backend instance. | |
UseCacheBackendTrait:: |
protected | property | Flag whether caches should be used or skipped. | |
UseCacheBackendTrait:: |
protected | function | Fetches from the cache backend, respecting the use caches flag. | 1 |
UseCacheBackendTrait:: |
protected | function | Stores data in the persistent cache, respecting the use caches flag. |