diff --git a/core/lib/Drupal/Core/Action/ActionManager.php b/core/lib/Drupal/Core/Action/ActionManager.php index c987d8c80cf..a3bfeda16f5 100644 --- a/core/lib/Drupal/Core/Action/ActionManager.php +++ b/core/lib/Drupal/Core/Action/ActionManager.php @@ -28,7 +28,7 @@ class ActionManager extends PluginManagerBase { * keyed by the corresponding namespace to look for plugin implementations. */ public function __construct(\Traversable $namespaces) { - $this->discovery = new AnnotatedClassDiscovery('Action', $namespaces, array(), 'Drupal\Core\Annotation\Action'); + $this->discovery = new AnnotatedClassDiscovery('Plugin/Action', $namespaces, array(), 'Drupal\Core\Annotation\Action'); $this->discovery = new AlterDecorator($this->discovery, 'action_info'); $this->factory = new ContainerFactory($this); diff --git a/core/lib/Drupal/Core/Archiver/ArchiverManager.php b/core/lib/Drupal/Core/Archiver/ArchiverManager.php index f3bfc966f9b..526dcdc571e 100644 --- a/core/lib/Drupal/Core/Archiver/ArchiverManager.php +++ b/core/lib/Drupal/Core/Archiver/ArchiverManager.php @@ -31,7 +31,7 @@ class ArchiverManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Archiver', $namespaces); + parent::__construct('Plugin/Archiver', $namespaces); $this->alterInfo($module_handler, 'archiver_info'); $this->setCacheBackend($cache_backend, $language_manager, 'archiver_info'); } diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php index 289774325d9..7f5d6305039 100644 --- a/core/lib/Drupal/Core/Condition/ConditionManager.php +++ b/core/lib/Drupal/Core/Condition/ConditionManager.php @@ -39,7 +39,7 @@ class ConditionManager extends DefaultPluginManager implements ExecutableManager $annotation_namespaces = array( 'Drupal\Core\Condition\Annotation' => DRUPAL_ROOT . '/core/lib', ); - parent::__construct('Condition', $namespaces, $annotation_namespaces, 'Drupal\Core\Condition\Annotation\Condition'); + parent::__construct('Plugin/Condition', $namespaces, $annotation_namespaces, 'Drupal\Core\Condition\Annotation\Condition'); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 4766a91e09e..3312d3a2591 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -112,7 +112,7 @@ class EntityManager extends PluginManagerBase { $this->cache = $cache; $this->languageManager = $language_manager; - $this->discovery = new AnnotatedClassDiscovery('Core/Entity', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); + $this->discovery = new AnnotatedClassDiscovery('Plugin/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:' . $this->languageManager->getLanguage(Language::TYPE_INTERFACE)->id, 'cache', CacheBackendInterface::CACHE_PERMANENT, array('entity_info' => TRUE)); diff --git a/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php index 9f9ceb8f5e9..a8c1ef5dd1d 100644 --- a/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldTypePluginManager.php @@ -45,7 +45,7 @@ class FieldTypePluginManager extends DefaultPluginManager { $annotation_namespaces = array( 'Drupal\Core\Entity\Annotation' => DRUPAL_ROOT . '/core/lib', ); - parent::__construct('field/field_type', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\FieldType'); + parent::__construct('Plugin/field/field_type', $namespaces, $annotation_namespaces, 'Drupal\Core\Entity\Annotation\FieldType'); $this->alterInfo($module_handler, 'field_info'); $this->setCacheBackend($cache_backend, $language_manager, 'field_types'); diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php index 7857f7a910a..f4aab248fd3 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionManager.php +++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php @@ -59,7 +59,7 @@ class LocalActionManager extends DefaultPluginManager { * The module handler. */ public function __construct(\Traversable $namespaces, ControllerResolverInterface $controller_resolver, Request $request, ModuleHandlerInterface $module_handler) { - parent::__construct('Menu\LocalAction', $namespaces, array(), 'Drupal\Core\Annotation\Menu\LocalAction'); + parent::__construct('Plugin/Menu/LocalAction', $namespaces, array(), 'Drupal\Core\Annotation\Menu\LocalAction'); $this->controllerResolver = $controller_resolver; $this->request = $request; diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index 12c501cbc85..00837c5f147 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -66,7 +66,7 @@ class LocalTaskManager extends DefaultPluginManager { * The module handler.u */ public function __construct(\Traversable $namespaces, ControllerResolverInterface $controller_resolver, Request $request, RouteProviderInterface $route_provider, ModuleHandlerInterface $module_handler) { - parent::__construct('Menu\LocalTask', $namespaces, array(), 'Drupal\Core\Annotation\Menu\LocalTask'); + parent::__construct('Plugin/Menu/LocalTask', $namespaces, array(), 'Drupal\Core\Annotation\Menu\LocalTask'); $this->controllerResolver = $controller_resolver; $this->request = $request; $this->routeProvider = $route_provider; diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index b7b0557a7dc..daddaa75ab3 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -60,9 +60,10 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt protected $alterHook; /** - * The plugin's subdirectory, for example views/filter. + * The subdirectory within a namespace to look for plugins, or FALSE if the + * plugins are in the top level of the namespace. * - * @var string + * @var string|bool */ protected $subdir; @@ -83,11 +84,11 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt /** * Creates the discovery object. * - * @param string $subdir - * The plugin's subdirectory, for example views/filter. + * @param string|bool $subdir + * The plugin's subdirectory, for example Plugin/views/filter. * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths - * keyed by the corresponding namespace to look for plugin implementations + * keyed by the corresponding namespace to look for plugin implementations. * @param array $annotation_namespaces * (optional) The namespaces of classes that can be used as annotations. * Defaults to an empty array. diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php index 6695db76db0..63c87ab0776 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -15,18 +15,14 @@ use Drupal\Component\Plugin\Discovery\AnnotatedClassDiscovery as ComponentAnnota class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery { /** - * The module name that defines the plugin type. + * The subdirectory within a namespace to look for plugins. + * + * If the plugins are in the top level of the namespace and not within a + * subdirectory, set this to an empty string. * * @var string */ - protected $owner; - - /** - * The plugin type, for example filter. - * - * @var string - */ - protected $type; + protected $subdir = ''; /** * An object containing the namespaces to look for plugin implementations. @@ -39,11 +35,12 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery { * Constructs an AnnotatedClassDiscovery object. * * @param string $subdir - * The plugin's subdirectory, for example views/filter. + * Either the plugin's subdirectory, for example 'Plugin/views/filter', or + * empty string if plugins are located at the top level of the namespace. * @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\$subdir will be appended to each namespace. + * keyed by the corresponding namespace to look for plugin implementations. + * If $subdir is not an empty string, it 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. @@ -52,7 +49,9 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery { * Defaults to 'Drupal\Component\Annotation\Plugin'. */ function __construct($subdir, \Traversable $root_namespaces, $annotation_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') { - $this->subdir = str_replace('/', '\\', $subdir); + if ($subdir) { + $this->subdir = str_replace('/', '\\', $subdir); + } $this->rootNamespacesIterator = $root_namespaces; $annotation_namespaces += array( 'Drupal\Component\Annotation' => DRUPAL_ROOT . '/core/lib', @@ -101,7 +100,10 @@ class AnnotatedClassDiscovery extends ComponentAnnotatedClassDiscovery { protected function getPluginNamespaces() { $plugin_namespaces = array(); foreach ($this->rootNamespacesIterator as $namespace => $dir) { - $plugin_namespaces["$namespace\\Plugin\\{$this->subdir}"] = array($dir); + if ($this->subdir) { + $namespace .= "\\{$this->subdir}"; + } + $plugin_namespaces[$namespace] = array($dir); } return $plugin_namespaces; diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 5c48fb03508..f217fa5ce5c 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -52,7 +52,7 @@ class TypedDataManager extends DefaultPluginManager { $annotation_namespaces = array( 'Drupal\Core\TypedData\Annotation' => DRUPAL_ROOT . '/core/lib', ); - parent::__construct('DataType', $namespaces, $annotation_namespaces, 'Drupal\Core\TypedData\Annotation\DataType'); + parent::__construct('Plugin/DataType', $namespaces, $annotation_namespaces, 'Drupal\Core\TypedData\Annotation\DataType'); } /** diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index 12849784b8f..91551bc187c 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -47,7 +47,7 @@ class ConstraintManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Validation/Constraint', $namespaces); + parent::__construct('Plugin/Validation/Constraint', $namespaces); $this->discovery = new StaticDiscoveryDecorator($this->discovery, array($this, 'registerDefinitions')); $this->alterInfo($module_handler, 'validation_constraint'); $this->setCacheBackend($cache_backend, $language_manager, 'validation_constraint'); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php index 2aa673159d4..67d8c4dbd67 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php @@ -38,7 +38,7 @@ class AggregatorPluginManager extends PluginManagerBase { 'Drupal\aggregator\Annotation' => DRUPAL_ROOT . '/core/modules/aggregator/lib', ); - $this->discovery = new AnnotatedClassDiscovery("aggregator/$type", $namespaces, $annotation_namespaces, $type_annotations[$type]); + $this->discovery = new AnnotatedClassDiscovery("Plugin/aggregator/$type", $namespaces, $annotation_namespaces, $type_annotations[$type]); $this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(Language::TYPE_INTERFACE)->id); $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 3963262344f..34daaca738f 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -33,7 +33,7 @@ class BlockManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Block', $namespaces); + parent::__construct('Plugin/Block', $namespaces); $this->alterInfo($module_handler, 'block'); $this->setCacheBackend($cache_backend, $language_manager, 'block_plugins'); } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php index 9ed45b83ccc..da2bcfd8a71 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php @@ -34,7 +34,7 @@ class CKEditorPluginManager extends DefaultPluginManager { */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { $annotation_namespaces = array('Drupal\ckeditor\Annotation' => $namespaces['Drupal\ckeditor']); - parent::__construct('CKEditorPlugin', $namespaces, $annotation_namespaces, 'Drupal\ckeditor\Annotation\CKEditorPlugin'); + parent::__construct('Plugin/CKEditorPlugin', $namespaces, $annotation_namespaces, 'Drupal\ckeditor\Annotation\CKEditorPlugin'); $this->alterInfo($module_handler, 'ckeditor_plugin_info'); $this->setCacheBackend($cache_backend, $language_manager, 'ckeditor_plugin'); } diff --git a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php index f4c544b9a0f..79f8013d372 100644 --- a/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php +++ b/core/modules/edit/lib/Drupal/edit/Plugin/InPlaceEditorManager.php @@ -30,7 +30,7 @@ class InPlaceEditorManager extends PluginManagerBase { */ public function __construct(\Traversable $namespaces) { $annotation_namespaces = array('Drupal\edit\Annotation' => $namespaces['Drupal\edit']); - $this->discovery = new AnnotatedClassDiscovery('InPlaceEditor', $namespaces, $annotation_namespaces, 'Drupal\edit\Annotation\InPlaceEditor'); + $this->discovery = new AnnotatedClassDiscovery('Plugin/InPlaceEditor', $namespaces, $annotation_namespaces, 'Drupal\edit\Annotation\InPlaceEditor'); $this->discovery = new AlterDecorator($this->discovery, 'edit_editor'); $this->discovery = new CacheDecorator($this->discovery, 'edit:editor'); $this->factory = new DefaultFactory($this->discovery); diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php index c6126c63fac..9adf2676c9d 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php @@ -32,7 +32,7 @@ class EditorManager extends DefaultPluginManager { */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { $annotation_namespaces = array('Drupal\editor\Annotation' => $namespaces['Drupal\editor']); - parent::__construct('Editor', $namespaces, $annotation_namespaces, 'Drupal\editor\Annotation\Editor'); + parent::__construct('Plugin/Editor', $namespaces, $annotation_namespaces, 'Drupal\editor\Annotation\Editor'); $this->alterInfo($module_handler, 'editor_info'); $this->setCacheBackend($cache_backend, $language_manager, 'editor'); } 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 c5ecb8ff213..bce6ebfb8ae 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 @@ -25,11 +25,8 @@ class SelectionPluginManager extends DefaultPluginManager { * {@inheritdoc} */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - $this->subdir = 'entity_reference/selection'; - $annotation_namespaces = array( - 'Drupal\entity_reference\Annotation' => $namespaces['Drupal\entity_reference'] - ); - $this->discovery = new AnnotatedClassDiscovery($this->subdir, $namespaces, $annotation_namespaces, 'Drupal\entity_reference\Annotation\EntityReferenceSelection'); + $annotation_namespaces = array('Drupal\entity_reference\Annotation' => $namespaces['Drupal\entity_reference']); + $this->discovery = new AnnotatedClassDiscovery('Plugin/entity_reference/selection', $namespaces, $annotation_namespaces, 'Drupal\entity_reference\Annotation\EntityReferenceSelection'); // We're not using the parent constructor because we use a different factory // method and don't need the derivative discovery decorator. 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 6eb0c9a73c2..2e19a0f973f 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 @@ -46,7 +46,7 @@ class FormatterPluginManager extends DefaultPluginManager { public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager) { $annotation_namespaces = array('Drupal\field\Annotation' => $namespaces['Drupal\field']); - parent::__construct('field/formatter', $namespaces, $annotation_namespaces, 'Drupal\field\Annotation\FieldFormatter'); + parent::__construct('Plugin/field/formatter', $namespaces, $annotation_namespaces, 'Drupal\field\Annotation\FieldFormatter'); $this->setCacheBackend($cache_backend, $language_manager, 'field_formatter_types'); $this->alterInfo($module_handler, 'field_formatter_info'); 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 6ab6eef759b..a5140f9edbc 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 @@ -46,7 +46,7 @@ class WidgetPluginManager extends DefaultPluginManager { public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager) { $annotation_namespaces = array('Drupal\field\Annotation' => $namespaces['Drupal\field']); - parent::__construct('field/widget', $namespaces, $annotation_namespaces, 'Drupal\field\Annotation\FieldWidget'); + parent::__construct('Plugin/field/widget', $namespaces, $annotation_namespaces, 'Drupal\field\Annotation\FieldWidget'); $this->setCacheBackend($cache_backend, $language_manager, 'field_widget_types'); $this->alterInfo($module_handler, 'field_widget_info'); diff --git a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php index 881cdf71359..21d34863f9d 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php +++ b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php @@ -31,7 +31,7 @@ class FilterPluginManager extends PluginManagerBase { */ public function __construct(\Traversable $namespaces) { $annotation_namespaces = array('Drupal\filter\Annotation' => $namespaces['Drupal\filter']); - $this->discovery = new AnnotatedClassDiscovery('Filter', $namespaces, $annotation_namespaces, 'Drupal\filter\Annotation\Filter'); + $this->discovery = new AnnotatedClassDiscovery('Plugin/Filter', $namespaces, $annotation_namespaces, 'Drupal\filter\Annotation\Filter'); $this->discovery = new AlterDecorator($this->discovery, 'filter_info'); $cache_key = 'filter_plugins:' . language(Language::TYPE_INTERFACE)->id; $cache_tags = array('filter_formats' => TRUE); diff --git a/core/modules/image/lib/Drupal/image/ImageEffectManager.php b/core/modules/image/lib/Drupal/image/ImageEffectManager.php index 95fc4c15202..64e251e955e 100644 --- a/core/modules/image/lib/Drupal/image/ImageEffectManager.php +++ b/core/modules/image/lib/Drupal/image/ImageEffectManager.php @@ -22,7 +22,7 @@ class ImageEffectManager extends DefaultPluginManager { */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { $annotation_namespaces = array('Drupal\image\Annotation' => $namespaces['Drupal\image']); - parent::__construct('ImageEffect', $namespaces, $annotation_namespaces, 'Drupal\image\Annotation\ImageEffect'); + parent::__construct('Plugin/ImageEffect', $namespaces, $annotation_namespaces, 'Drupal\image\Annotation\ImageEffect'); $this->alterInfo($module_handler, 'image_effect_info'); $this->setCacheBackend($cache_backend, $language_manager, 'image_effect'); 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 e22623f1ea0..248414efe89 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', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('Plugin/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 6edea1718c2..602063458ca 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php @@ -28,7 +28,7 @@ class ResourcePluginManager extends PluginManagerBase { */ public function __construct(\Traversable $namespaces) { // Create resource plugin derivatives from declaratively defined resources. - $this->discovery = new AnnotatedClassDiscovery('rest/resource', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('Plugin/rest/resource', $namespaces); $this->discovery = new DerivativeDiscoveryDecorator($this->discovery); $this->discovery = new AlterDecorator($this->discovery, 'rest_resource'); $this->discovery = new CacheDecorator($this->discovery, 'rest'); diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php index ddad9c64968..f8e334da96a 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkitManager.php @@ -28,7 +28,7 @@ class ImageToolkitManager extends DefaultPluginManager { * The language manager. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager) { - parent::__construct('ImageToolkit', $namespaces); + parent::__construct('Plugin/ImageToolkit', $namespaces); $this->setCacheBackend($cache_backend, $language_manager, 'image_toolkit'); } 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 0514fe386a6..9328a5c3394 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('PluginUI', $namespaces); + $this->discovery = new AnnotatedClassDiscovery('Plugin/PluginUI', $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 5f8ee2d0896..6f43b57b806 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 @@ -58,8 +58,8 @@ class AnnotatedClassDiscoveryTest extends DiscoveryTestBase { ), ); $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/plugin_test/fruit', $namespaces); + $this->emptyDiscovery = new AnnotatedClassDiscovery('Plugin/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 cbf2a16b374..b5729199297 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 @@ -46,8 +46,8 @@ class CustomAnnotationClassDiscoveryTest extends DiscoveryTestBase { '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/plugin_test/custom_annotation', $root_namespaces, $annotation_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample'); + $this->emptyDiscovery = new AnnotatedClassDiscovery('Plugin/non_existing_module/non_existing_plugin_type', $root_namespaces, $annotation_namespaces, 'Drupal\plugin_test\Plugin\Annotation\PluginExample'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php new file mode 100644 index 00000000000..c005300f847 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/CustomDirectoryAnnotatedClassDiscoveryTest.php @@ -0,0 +1,48 @@ + 'Custom directory annotation class discovery', + 'description' => 'Tests that plugins in a custom directory are correctly discovered using annotated classes.', + 'group' => 'Plugin API', + ); + } + + protected function setUp() { + parent::setUp(); + + $this->expectedDefinitions = array( + 'custom_example_1' => array( + 'id' => 'custom_example_1', + 'custom' => 'Tim', + 'class' => 'Drupal\plugin_test\CustomDirectoryExample1', + 'provider' => 'plugin_test', + ), + 'custom_example_2' => array( + 'id' => 'custom_example_2', + 'custom' => 'Meghan', + 'class' => 'Drupal\plugin_test\CustomDirectoryExample2', + 'provider' => 'plugin_test', + ), + ); + $namespaces = new \ArrayObject(array('Drupal\plugin_test' => DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/lib')); + $this->discovery = new AnnotatedClassDiscovery('', $namespaces); + $empty_namespaces = new \ArrayObject(); + $this->emptyDiscovery = new AnnotatedClassDiscovery('', $empty_namespaces); + } + +} diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/CustomDirectoryExample1.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/CustomDirectoryExample1.php new file mode 100644 index 00000000000..b3be67cd1e6 --- /dev/null +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/CustomDirectoryExample1.php @@ -0,0 +1,20 @@ + $namespaces['Drupal\tour']); - parent::__construct('tour/tip', $namespaces, $annotation_namespaces, 'Drupal\tour\Annotation\Tip'); + parent::__construct('Plugin/tour/tip', $namespaces, $annotation_namespaces, 'Drupal\tour\Annotation\Tip'); $this->alterInfo($module_handler, 'tour_tips_info'); $this->setCacheBackend($cache_backend, $language_manager, 'tour'); diff --git a/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php index 2b8c6a65c81..3e6099e96e0 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("Plugin/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);