You are here

protected function DefaultPluginManager::extractProviderFromDefinition in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/DefaultPluginManager.php \Drupal\Core\Plugin\DefaultPluginManager::extractProviderFromDefinition()
  2. 10 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 310

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'];
  }
}