You are here

public function CToolsPluginDiscovery::getDefinition in Service Container 7.2

Same name and namespace in other branches
  1. 7 src/Plugin/Discovery/CToolsPluginDiscovery.php \Drupal\service_container\Plugin\Discovery\CToolsPluginDiscovery::getDefinition()

Gets a specific plugin definition.

Parameters

string $plugin_id: A plugin id.

bool $exception_on_invalid: (optional) If TRUE, an invalid plugin ID will throw an exception.

Return value

mixed A plugin definition, or NULL if the plugin ID is invalid and $exception_on_invalid is FALSE.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if $plugin_id is invalid and $exception_on_invalid is TRUE.

Overrides DiscoveryInterface::getDefinition

1 call to CToolsPluginDiscovery::getDefinition()
CToolsPluginDiscovery::hasDefinition in src/Plugin/Discovery/CToolsPluginDiscovery.php
Indicates if a specific plugin definition exists.

File

src/Plugin/Discovery/CToolsPluginDiscovery.php, line 57
Contains \Drupal\service_container\Plugin\Discovery\CToolsPluginDiscovery

Class

CToolsPluginDiscovery
A discovery mechanism that uses ctools plugins for Drupal 7 compatibility.

Namespace

Drupal\service_container\Plugin\Discovery

Code

public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
  ctools_include('plugins');
  $definition = ctools_get_plugins($this->pluginOwner, $this->pluginType, $plugin_id);
  if (!$definition && $exception_on_invalid) {
    throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist.', $plugin_id));
  }
  return $definition;
}