public function DerivativeDiscoveryDecorator::getDefinition in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator::getDefinition()
Throws
\Drupal\Component\Plugin\Exception\InvalidDeriverException Thrown if the 'deriver' class specified in the plugin definition does not implement \Drupal\Component\Plugin\Derivative\DeriverInterface.
Overrides DiscoveryTrait::getDefinition
File
- lib/
Drupal/ Component/ Plugin/ Discovery/ DerivativeDiscoveryDecorator.php, line 55 - Contains \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator.
Class
- DerivativeDiscoveryDecorator
- Base class providing the tools for a plugin discovery to be derivative aware.
Namespace
Drupal\Component\Plugin\DiscoveryCode
public function getDefinition($plugin_id, $exception_on_invalid = TRUE) {
// This check is only for derivative plugins that have explicitly provided
// an ID. This is not common, and can be expected to fail. Therefore, opt
// out of the thrown exception, which will be handled when checking the
// $base_plugin_id.
$plugin_definition = $this->decorated
->getDefinition($plugin_id, FALSE);
list($base_plugin_id, $derivative_id) = $this
->decodePluginId($plugin_id);
$base_plugin_definition = $this->decorated
->getDefinition($base_plugin_id, $exception_on_invalid);
if ($base_plugin_definition) {
$deriver = $this
->getDeriver($base_plugin_id, $base_plugin_definition);
if ($deriver) {
$derivative_plugin_definition = $deriver
->getDerivativeDefinition($derivative_id, $base_plugin_definition);
// If a plugin defined itself as a derivative, merge in possible
// defaults from the derivative.
if ($derivative_id && isset($plugin_definition)) {
$plugin_definition = $this
->mergeDerivativeDefinition($plugin_definition, $derivative_plugin_definition);
}
else {
$plugin_definition = $derivative_plugin_definition;
}
}
}
return $plugin_definition;
}