diff --git a/core/lib/Drupal/Component/Plugin/Discovery/ProcessDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/ProcessDecorator.php index 2e31dbc..bcb5cad 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/ProcessDecorator.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/ProcessDecorator.php @@ -8,7 +8,10 @@ namespace Drupal\Component\Plugin\Discovery; /** - * Allows custom processing of the discovered definition.. + * Allows custom processing of the discovered definition. + * + * Example use cases include adding in default values for a definition, or + * providing a backwards compatibility layer for renamed definition properties. */ class ProcessDecorator implements DiscoveryInterface { @@ -20,27 +23,27 @@ class ProcessDecorator implements DiscoveryInterface { protected $decorated; /** - * The processor function to run on each discovered definition. + * The processor callback to run on each discovered definition. * * @var callable */ - protected $processFunction; + protected $processCallback; /** * Constructs a \Drupal\Component\Plugin\Discovery\ProcessDecorator object. * * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated * The discovery object that is being decorated. - * @param callable $process_function - * The processor function to run on each discovered definition. The - * function will be called with the following arguments: - * - array $definition: the discovered definition, that the function + * @param callable $process_callback + * The processor callback to run on each discovered definition. The + * callback will be called with the following arguments: + * - array $definition: the discovered definition, that the callback * should accept by reference and modify in place. * - string $plugin_id: the corresponding plugin_id. */ - public function __construct(DiscoveryInterface $decorated, $process_function) { + public function __construct(DiscoveryInterface $decorated, $process_callback) { $this->decorated = $decorated; - $this->processFunction = $process_function; + $this->processCallback = $process_callback; } /** @@ -48,7 +51,9 @@ public function __construct(DiscoveryInterface $decorated, $process_function) { */ public function getDefinition($plugin_id) { $definitions = $this->getDefinitions(); - return isset($definitions[$plugin_id]) ? $definitions[$plugin_id] : NULL; + if (isset($definitions[$plugin_id])) { + return $definitions[$plugin_id]; + } } /** @@ -57,7 +62,7 @@ public function getDefinition($plugin_id) { public function getDefinitions() { $definitions = $this->decorated->getDefinitions(); foreach ($definitions as $plugin_id => &$definition) { - call_user_func_array($this->processFunction, array(&$definition, $plugin_id)); + call_user_func_array($this->processCallback, array(&$definition, $plugin_id)); } return $definitions; } @@ -68,4 +73,5 @@ public function getDefinitions() { public function __call($method, $args) { return call_user_func_array(array($this->decorated, $method), $args); } + }