diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php index 84cb550..ba069d6 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -17,38 +17,25 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery { /** * Constructs an AnnotatedClassDiscovery object. * + * @param string $owner + * The plugin type owner. + * @param string $type + * The plugin type name. + * @param array $root_namespaces + * Array of root paths keyed by the corresponding namespace to look for + * plugin implementations, \Plugin\$owner\$type will be appended to each + * of those. * @param array $plugin_namespaces * An array of paths keyed by it's corresponding namespaces. */ - function __construct($owner, $type, $root_namespaces = NULL, array $plugin_namespaces = array()) { - $this->owner = $owner; - $this->type = $type; - $this->rootNamespaces = $root_namespaces; - $this->pluginNamespaces = $plugin_namespaces; + function __construct($owner, $type, array $root_namespaces = array(), array $plugin_namespaces = array()) { + foreach ($root_namespaces as $namespace => $dir) { + $plugin_namespaces["$namespace\\Plugin\\$owner\\$type"] = array($dir); + } $annotation_namespaces = array( 'Drupal\Component\Annotation' => DRUPAL_ROOT . '/core/lib', 'Drupal\Core\Annotation' => DRUPAL_ROOT . '/core/lib', ); - parent::__construct(array(), $annotation_namespaces, 'Drupal\Core\Annotation\Plugin'); + parent::__construct($plugin_namespaces, $annotation_namespaces, 'Drupal\Core\Annotation\Plugin'); } - - /** - * Overrides Drupal\Component\Plugin\Discovery\AnnotatedClassDiscovery::getPluginNamespaces(). - * - * @todo Figure out how to let this comment still be TRUE. - * This is overridden rather than set in the constructor, because Drupal - * modules can be enabled (and therefore, namespaces registered) during the - * lifetime of a plugin manager. - */ - protected function getPluginNamespaces() { - if (!empty($this->plugin_namespaces)) { - return parent::getPluginNamespaces(); - } - $plugin_namespaces = array(); - foreach ($this->rootNamespaces as $namespace => $dir) { - $plugin_namespaces["$namespace\\Plugin\\{$this->owner}\\{$this->type}"] = array($dir); - } - return $plugin_namespaces; - } - }