function DefaultPluginManager::processDefinition

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/DefaultPluginManager.php \Drupal\Core\Plugin\DefaultPluginManager::processDefinition()
  2. 8.9.x core/lib/Drupal/Core/Plugin/DefaultPluginManager.php \Drupal\Core\Plugin\DefaultPluginManager::processDefinition()
  3. 10 core/lib/Drupal/Core/Plugin/DefaultPluginManager.php \Drupal\Core\Plugin\DefaultPluginManager::processDefinition()

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.

3 calls to DefaultPluginManager::processDefinition()
DefaultPluginManager::findDefinitions in core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
Finds plugin definitions.
MigrateSourcePluginManager::findDefinitions in core/modules/migrate/src/Plugin/MigrateSourcePluginManager.php
Finds plugin definitions.
MigrationPluginManager::findDefinitions in core/modules/migrate/src/Plugin/MigrationPluginManager.php
Finds plugin definitions.
14 methods override DefaultPluginManager::processDefinition()
BlockManager::processDefinition in core/lib/Drupal/Core/Block/BlockManager.php
Performs extra processing on plugin definitions.
BreakpointManager::processDefinition in core/modules/breakpoint/src/BreakpointManager.php
Performs extra processing on plugin definitions.
CategorizingPluginManager::processDefinition in core/tests/Drupal/Tests/Core/Plugin/CategorizingPluginManagerTraitTest.php
Performs extra processing on plugin definitions.
CKEditor5PluginManager::processDefinition in core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php
Performs extra processing on plugin definitions.
ConfigMapperManager::processDefinition in core/modules/config_translation/src/ConfigMapperManager.php
Performs extra processing on plugin definitions.

... See full list

File

core/lib/Drupal/Core/Plugin/DefaultPluginManager.php, line 285

Class

DefaultPluginManager
Base class for plugin managers.

Namespace

Drupal\Core\Plugin

Code

public function processDefinition(&$definition, $plugin_id) {
    // Only array-based definitions can have defaults merged in.
    if (is_array($definition) && !empty($this->defaults) && is_array($this->defaults)) {
        $definition = NestedArray::mergeDeep($this->defaults, $definition);
    }
    // Keep class definitions standard with no leading slash.
    if ($definition instanceof PluginDefinitionInterface) {
        assert(is_string($definition->getClass()), 'Plugin definitions must have a class');
        $definition->setClass(ltrim($definition->getClass(), '\\'));
    }
    elseif (is_array($definition) && isset($definition['class'])) {
        $definition['class'] = ltrim($definition['class'], '\\');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.