function DefaultPluginManager::fixContextAwareDefinitions

Fix the definitions of context-aware plugins.

@todo Remove before Drupal 9.0.0.

Parameters

array $definitions: The array of plugin definitions.

1 call to DefaultPluginManager::fixContextAwareDefinitions()
DefaultPluginManager::findDefinitions in core/lib/Drupal/Core/Plugin/DefaultPluginManager.php
Finds plugin definitions.

File

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

Class

DefaultPluginManager
Base class for plugin managers.

Namespace

Drupal\Core\Plugin

Code

private function fixContextAwareDefinitions(array &$definitions) {
    foreach ($definitions as $name => &$definition) {
        if (is_array($definition) && (!empty($definition['context']) || !empty($definition['context_definitions']))) {
            // Ensure the new definition key is available.
            if (!isset($definition['context_definitions'])) {
                $definition['context_definitions'] = [];
            }
            // If a context definition is defined with the old key, add it to the
            // new key and trigger a deprecation error.
            if (!empty($definition['context'])) {
                $definition['context_definitions'] += $definition['context'];
                @trigger_error('Providing context definitions via the "context" key is deprecated in Drupal 8.7.x and will be removed before Drupal 9.0.0. Use the "context_definitions" key instead.', E_USER_DEPRECATED);
            }
            // Copy the context definitions from the new key to the old key for
            // backwards compatibility.
            if (isset($definition['context'])) {
                $definition['context'] = $definition['context_definitions'];
            }
        }
    }
}

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