diff --git a/core/lib/Drupal/Core/Archiver/ArchiverManager.php b/core/lib/Drupal/Core/Archiver/ArchiverManager.php index fd1165b..ed7b016 100644 --- a/core/lib/Drupal/Core/Archiver/ArchiverManager.php +++ b/core/lib/Drupal/Core/Archiver/ArchiverManager.php @@ -25,7 +25,7 @@ class ArchiverManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('Core', 'Archiver', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('Core/Archiver', $namespaces); $this->discovery = new AlterDecorator($this->discovery, 'archiver_info'); $this->discovery = new CacheDecorator($this->discovery, 'archiver_info'); } diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php index ffa22fd..435fcfb 100644 --- a/core/lib/Drupal/Core/Condition/ConditionManager.php +++ b/core/lib/Drupal/Core/Condition/ConditionManager.php @@ -29,7 +29,7 @@ class ConditionManager extends PluginManagerBase implements ExecutableManagerInt * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('Core', 'Condition', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('Core/Condition', $namespaces); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new AlterDecorator($this->discovery, 'condition_info'); $this->discovery = new CacheDecorator($this->discovery, 'condition:' . language(LANGUAGE_TYPE_INTERFACE)->langcode); diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 1ad1495..9e1d12f 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -50,7 +50,7 @@ public function __construct(\Traversable $namespaces) { $annotation_namespaces = array( 'Drupal\Core\Entity\Annotation' => DRUPAL_ROOT . '/core/lib', ); - $this->discovery = new AnnotatedClassDiscovery('Core', 'Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); + $this->discovery = new AnnotatedClassDiscovery('Core/Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info'); $this->discovery = new AlterDecorator($this->discovery, 'entity_info'); $this->discovery = new CacheDecorator($this->discovery, 'entity_info:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php index 2694e33..d47049b 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -38,14 +38,12 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery { /** * Constructs an AnnotatedClassDiscovery object. * - * @param string $owner - * The module name that defines the plugin type. - * @param string $type - * The plugin type, for example filter. + * @param string $subdir + * The plugin's subdirectory, for example views/filter. * @param \Traversable $root_namespaces * An object that implements \Traversable which contains the root paths * keyed by the corresponding namespace to look for plugin implementations, - * \Plugin\$owner\$type will be appended to each namespace. + * \Plugin\$subdir will be appended to each namespace. * @param array $annotation_namespaces * (optional) The namespaces of classes that can be used as annotations. * Defaults to an empty array. @@ -53,9 +51,8 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery { * (optional) The name of the annotation that contains the plugin definition. * Defaults to 'Drupal\Component\Annotation\Plugin'. */ - function __construct($owner, $type, \Traversable $root_namespaces, $annotation_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') { - $this->owner = $owner; - $this->type = $type; + function __construct($subdir, \Traversable $root_namespaces, $annotation_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') { + $this->subdir = str_replace('\\', DIRECTORY_SEPARATOR, $subdir); $this->rootNamespacesIterator = $root_namespaces; $annotation_namespaces += array( 'Drupal\Component\Annotation' => DRUPAL_ROOT . '/core/lib', @@ -71,7 +68,7 @@ function __construct($owner, $type, \Traversable $root_namespaces, $annotation_n protected function getPluginNamespaces() { $plugin_namespaces = array(); foreach ($this->rootNamespacesIterator as $namespace => $dir) { - $plugin_namespaces["$namespace\\Plugin\\{$this->owner}\\{$this->type}"] = array($dir); + $plugin_namespaces["$namespace\\Plugin\\{$this->subdir}"] = array($dir); } return $plugin_namespaces; diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index 5c8719b..8afd195 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -44,7 +44,7 @@ class ConstraintManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('Validation', 'Constraint', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('Validation/Constraint', $namespaces); $this->discovery = new StaticDiscoveryDecorator($this->discovery, array($this, 'registerDefinitions')); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php index aaa6e3e..20ae316 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php @@ -27,7 +27,7 @@ class AggregatorPluginManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct($type, \Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('aggregator', $type, $namespaces); + $this->discovery = new AnnotatedClassDiscovery("aggregator/$type", $namespaces); $this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(LANGUAGE_TYPE_INTERFACE)->langcode); $this->factory = new DefaultFactory($this->discovery); } diff --git a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php index faf7500..f2417d6 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -32,7 +32,7 @@ class BlockManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('block', 'block', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('block/block', $namespaces); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new AlterDecorator($this->discovery, 'block'); $this->discovery = new CacheDecorator($this->discovery, 'block_plugins:' . language(LANGUAGE_TYPE_INTERFACE)->langcode, 'block', CacheBackendInterface::CACHE_PERMANENT, array('block')); diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php index 5386a9f..054cece 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php @@ -29,7 +29,7 @@ class CKEditorPluginManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('ckeditor', 'plugin', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('ckeditor/plugin', $namespaces); $this->discovery = new AlterDecorator($this->discovery, 'ckeditor_plugin_info'); $this->discovery = new CacheDecorator($this->discovery, 'ckeditor_plugin'); $this->factory = new DefaultFactory($this->discovery); diff --git a/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php b/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php index 8d0032f..96bbf36 100644 --- a/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php +++ b/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php @@ -29,7 +29,7 @@ class EditorManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('edit', 'editor', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('edit/editor', $namespaces); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new AlterDecorator($this->discovery, 'edit_editor'); $this->discovery = new CacheDecorator($this->discovery, 'edit:editor'); diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php index 989af1f..b94d259 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php @@ -27,7 +27,7 @@ class EditorManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('editor', 'editor', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('editor/editor', $namespaces); $this->discovery = new AlterDecorator($this->discovery, 'editor_info'); $this->discovery = new CacheDecorator($this->discovery, 'editor'); $this->factory = new DefaultFactory($this->discovery); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php index bd140a9..f178242 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php @@ -28,7 +28,7 @@ class SelectionPluginManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->baseDiscovery = new AlterDecorator(new AnnotatedClassDiscovery('entity_reference', 'selection', $namespaces), 'entity_reference_selection'); + $this->baseDiscovery = new AlterDecorator(new AnnotatedClassDiscovery('entity_reference/selection', $namespaces), 'entity_reference_selection'); $this->discovery = new CacheDecorator($this->baseDiscovery, 'entity_reference_selection'); $this->factory = new ReflectionFactory($this); } diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php index 90722d5..2260610 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php @@ -35,7 +35,7 @@ class FormatterPluginManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('field', 'formatter', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('field/formatter', $namespaces); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new AlterDecorator($this->discovery, 'field_formatter_info'); $this->discovery = new CacheDecorator($this->discovery, 'field_formatter_types', 'field'); diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php index 6cbad1f..c8ea1f9 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php @@ -36,7 +36,7 @@ class WidgetPluginManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('field', 'widget', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('field/widget', $namespaces); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new AlterDecorator($this->discovery, 'field_widget_info'); $this->discovery = new CacheDecorator($this->discovery, 'field_widget_types', 'field'); diff --git a/core/modules/layout/lib/Drupal/layout/Plugin/Type/LayoutManager.php b/core/modules/layout/lib/Drupal/layout/Plugin/Type/LayoutManager.php index 179ea4b..8004174 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/Type/LayoutManager.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/Type/LayoutManager.php @@ -31,7 +31,7 @@ class LayoutManager extends PluginManagerBase { */ public function __construct(\Traversable $namespaces) { // Create layout plugin derivatives from declaratively defined layouts. - $this->discovery = new AnnotatedClassDiscovery('layout', 'layout', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('layout/layout', $namespaces); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php index c23e970..1136376 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php @@ -26,7 +26,7 @@ class ResourcePluginManager extends PluginManagerBase { */ public function __construct(\Traversable $namespaces) { // Create resource plugin derivatives from declaratively defined resources. - $this->discovery = new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('rest', 'resource', $namespaces)); + $this->discovery = new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('rest/resource', $namespaces)); $this->factory = new ReflectionFactory($this->discovery); } diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php index c33f79a..173af94 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php @@ -24,7 +24,7 @@ class ImageToolkitManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('system', 'imagetoolkit', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('system/imagetoolkit', $namespaces); $this->factory = new DefaultFactory($this->discovery); } diff --git a/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php b/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php index bc371c0..c417ebd 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php @@ -29,7 +29,7 @@ class PluginUIManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('system', 'plugin_ui', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('system/plugin_ui', $namespaces); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new AlterDecorator($this->discovery, 'plugin_ui'); $this->discovery = new CacheDecorator($this->discovery, 'plugin_ui'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php index b54b064..0071f70 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php @@ -54,8 +54,8 @@ public function setUp() { ), ); $namespaces = new \ArrayObject(array('Drupal\plugin_test' => DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/lib')); - $this->discovery = new AnnotatedClassDiscovery('plugin_test', 'fruit', $namespaces); - $this->emptyDiscovery = new AnnotatedClassDiscovery('non_existing_module', 'non_existing_plugin_type', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('plugin_test/fruit', $namespaces); + $this->emptyDiscovery = new AnnotatedClassDiscovery('non_existing_module/non_existing_plugin_type', $namespaces); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php index 849933b..5ed2c5e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomAnnotationClassDiscoveryTest.php @@ -44,8 +44,8 @@ protected function setUp() { 'Drupal\plugin_test\Plugin\Annotation' => DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/lib', ); - $this->discovery = new AnnotatedClassDiscovery('plugin_test', 'custom_annotation', $root_namespaces, $annotation_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample'); - $this->emptyDiscovery = new AnnotatedClassDiscovery('non_existing_module', 'non_existing_plugin_type', $root_namespaces, $annotation_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample'); + $this->discovery = new AnnotatedClassDiscovery('plugin_test/custom_annotation', $root_namespaces, $annotation_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample'); + $this->emptyDiscovery = new AnnotatedClassDiscovery('non_existing_module/non_existing_plugin_type', $root_namespaces, $annotation_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample'); } } diff --git a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php index ddcc307..03658be 100644 --- a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php +++ b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php @@ -27,7 +27,7 @@ class TipPluginManager extends PluginManagerBase { */ public function __construct(\Traversable $namespaces) { $annotation_namespaces = array('Drupal\tour\Annotation' => $namespaces['Drupal\tour']); - $this->discovery = new AnnotatedClassDiscovery('tour', 'tip', $namespaces, $annotation_namespaces, 'Drupal\tour\Annotation\Tip'); + $this->discovery = new AnnotatedClassDiscovery('tour/tip', $namespaces, $annotation_namespaces, 'Drupal\tour\Annotation\Tip'); $this->discovery = new CacheDecorator($this->discovery, 'tour'); $this->factory = new DefaultFactory($this->discovery); diff --git a/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php index 4413b00..2b8c6a6 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php +++ b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php @@ -31,7 +31,7 @@ class ViewsPluginManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations, */ public function __construct($type, \Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('views', $type, $namespaces); + $this->discovery = new AnnotatedClassDiscovery("views/$type", $namespaces); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new AlterDecorator($this->discovery, 'views_plugins_' . $type);