public function AnnotatedClassDiscovery::getDefinition in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_annotation_discovery/src/Plugin/Discovery/AnnotatedClassDiscovery.php \Drupal\service_container_annotation_discovery\Plugin\Discovery\AnnotatedClassDiscovery::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 AnnotatedClassDiscovery::getDefinition()
- AnnotatedClassDiscovery::hasDefinition in modules/
providers/ service_container_annotation_discovery/ src/ Plugin/ Discovery/ AnnotatedClassDiscovery.php - Indicates if a specific plugin definition exists.
File
- modules/
providers/ service_container_annotation_discovery/ src/ Plugin/ Discovery/ AnnotatedClassDiscovery.php, line 169 - Contains \Drupal\service_container_annotation_discovery\Plugin\Discovery\AnnotatedClassDiscovery
Class
Namespace
Drupal\service_container_annotation_discovery\Plugin\DiscoveryCode
public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
$definitions = $this
->getDefinitions();
$definition = isset($definitions[$plugin_id]) ? $definitions[$plugin_id] : FALSE;
if (!$definition && $exception_on_invalid) {
throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist.', $plugin_id));
}
return $definition;
}