function DefaultPluginManager::extractProviderFromDefinition

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

Extracts the provider from a plugin definition.

Parameters

mixed $plugin_definition: The plugin definition. Usually either an array or an instance of \Drupal\Component\Plugin\Definition\PluginDefinitionInterface

Return value

string|null The provider string, if it exists. NULL otherwise.

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

File

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

Class

DefaultPluginManager
Base class for plugin managers.

Namespace

Drupal\Core\Plugin

Code

protected function extractProviderFromDefinition($plugin_definition) {
    if ($plugin_definition instanceof PluginDefinitionInterface) {
        return $plugin_definition->getProvider();
    }
    // Attempt to convert the plugin definition to an array.
    if (is_object($plugin_definition)) {
        $plugin_definition = (array) $plugin_definition;
    }
    if (isset($plugin_definition['provider'])) {
        return $plugin_definition['provider'];
    }
}

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