public function AllowedHtmlManager::processDefinition in Markdown 8.2
Performs extra processing on plugin definitions.
By default we add defaults for the type to the definition. If a type has additional processing logic they can do that by replacing or extending the method.
Overrides InstallablePluginManager::processDefinition
File
- src/
PluginManager/ AllowedHtmlManager.php, line 444
Class
- AllowedHtmlManager
- Markdown Allowed HTML Plugin Manager.
Namespace
Drupal\markdown\PluginManagerCode
public function processDefinition(&$definition, $plugin_id) {
if (!$definition instanceof MarkdownAllowedHtml || !($class = $definition
->getClass()) || $definition->requirementViolations) {
return;
}
// Handle deprecated "requiresFilter" property.
// @todo Deprecated property, remove before 3.0.0.
if ($filter = $definition->requiresFilter) {
if (!$definition
->getRequirementsByType('filter', $filter)) {
$requirement = InstallableRequirement::create();
$requirement->id = "filter:{$filter}";
$definition->requirements[] = $requirement;
}
unset($definition->requiresFilter);
}
// Certain types need to be determined prior to parent method processing.
if (!isset($definition->type)) {
$definition->type = 'other';
// Allow dependencies on filters.
if ($definition
->getRequirementsByType('filter')) {
$definition->type = 'filter';
}
elseif (is_subclass_of($class, ParserInterface::class)) {
$definition->type = 'parser';
if ($parserDefinition = $this->parserManager
->getDefinitionByClassName($class)) {
$requirement = InstallableRequirement::create();
$requirement->id = 'parser:' . $parserDefinition->id;
$definition->requirements[] = $requirement;
}
}
elseif (is_subclass_of($class, ExtensionInterface::class)) {
$definition->type = 'extension';
if ($extensionDefinition = $this->extensionManager
->getDefinitionByClassName($class)) {
$requirement = InstallableRequirement::create();
$requirement->id = 'extension:' . $extensionDefinition->id;
$definition->requirements[] = $requirement;
}
}
elseif ($this->moduleHandler
->moduleExists($definition->provider)) {
$definition->type = 'module';
}
elseif ($this->themeHandler
->themeExists($plugin_id)) {
$definition->type = 'theme';
}
}
parent::processDefinition($definition, $plugin_id);
}