protected function DiscoveryTrait::doGetDefinition in Plug 7
Gets a specific plugin definition.
Parameters
array $definitions: An array of the available plugin definitions.
string $plugin_id: A plugin id.
bool $exception_on_invalid: (optional) If TRUE, an invalid plugin ID will throw an exception. Defaults to FALSE.
Return value
array|null A plugin definition, or NULL if the plugin ID is invalid and $exception_on_invalid is TRUE.
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if $plugin_id is invalid and $exception_on_invalid is TRUE.
2 calls to DiscoveryTrait::doGetDefinition()
- DiscoveryCachedTrait::getDefinition in lib/
Drupal/ Component/ Plugin/ Discovery/ DiscoveryCachedTrait.php - DiscoveryTrait::getDefinition in lib/
Drupal/ Component/ Plugin/ Discovery/ DiscoveryTrait.php
File
- lib/
Drupal/ Component/ Plugin/ Discovery/ DiscoveryTrait.php, line 48 - Contains \Drupal\Component\Plugin\Discovery\DiscoveryTrait.
Class
Namespace
Drupal\Component\Plugin\DiscoveryCode
protected function doGetDefinition(array $definitions, $plugin_id, $exception_on_invalid) {
// Avoid using a ternary that would create a copy of the array.
if (isset($definitions[$plugin_id])) {
return $definitions[$plugin_id];
}
elseif (!$exception_on_invalid) {
return NULL;
}
throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist.', $plugin_id));
}