protected function AllowedHtmlManager::alterDefinition in Markdown 8.2
Allows plugin managers to further alter individual definitions.
Parameters
\Drupal\markdown\Annotation\InstallablePlugin $definition: The definition being altered.
bool $runtime: Flag indicating whether this is a runtime alteration.
Overrides InstallablePluginManager::alterDefinition
1 call to AllowedHtmlManager::alterDefinition()
- AllowedHtmlManager::alterDefinitions in src/
PluginManager/ AllowedHtmlManager.php - Invokes the hook to alter the definitions if the alter hook is set.
File
- src/
PluginManager/ AllowedHtmlManager.php, line 392
Class
- AllowedHtmlManager
- Markdown Allowed HTML Plugin Manager.
Namespace
Drupal\markdown\PluginManagerCode
protected function alterDefinition(InstallablePlugin $definition, $runtime = FALSE) {
// Immediately return if not altering the runtime definition.
if (!$runtime) {
return;
}
/* @var \Drupal\markdown\Annotation\MarkdownAllowedHtml $definition */
switch ($definition->type) {
case 'extension':
if (($extensionRequirement = current($definition
->getRequirementsByType('extension'))) && ($extensionDefinition = $this->extensionManager
->getDefinition($extensionRequirement
->getTypeId()))) {
$definition
->merge($extensionDefinition, [
'ui',
]);
}
break;
case 'filter':
if (($filterRequirement = current($definition
->getRequirementsByType('filter'))) && ($filterDefinition = $this->filterManager
->getDefinition($filterRequirement
->getTypeId()))) {
$definition
->merge($filterDefinition, [
'ui',
]);
if (empty($definition->label) && !empty($filterDefinition['title'])) {
$definition->label = $filterDefinition['title'];
}
}
break;
case 'parser':
if (($parserRequirement = current($definition
->getRequirementsByType('parser'))) && ($parserDefinition = $this->parserManager
->getDefinition($parserRequirement
->getTypeId()))) {
$definition
->merge($parserDefinition, [
'ui',
]);
}
break;
}
// Provide a default label if none was provided.
if (empty($definition->label)) {
// Use the provider name if plugin identifier is the same.
if ($definition->id === $definition->provider) {
$definition['label'] = $this
->getProviderName($definition->provider);
}
elseif ($definition->type !== 'extension') {
$definition['label'] = ucwords(trim(str_replace([
'_',
'-',
], ' ', $definition->id)));
}
}
// Prefix label with provider (if not the same).
if (in_array($definition->type, [
'filter',
'module',
'theme',
]) && $definition->id !== $definition->provider) {
$definition['label'] = $this
->getProviderName($definition->provider) . ': ' . $definition['label'];
}
}