diff --git a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php index d7fc8d6613a55e105e1a361ca017c576a875a33c..e245874d4c5cc03fc9c1ef9ab77da417baf80fcd 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php @@ -65,11 +65,6 @@ public function getDefinitions() { protected function getDerivatives(array $base_plugin_definitions) { $plugin_definitions = array(); foreach ($base_plugin_definitions as $base_plugin_id => $plugin_definition) { - // @todo Remove this check once http://drupal.org/node/1780396 is resolved. - if (isset($plugin_definition['module']) && !module_exists($plugin_definition['module'])) { - continue; - } - $derivative_fetcher = $this->getDerivativeFetcher($base_plugin_id, $plugin_definition); if ($derivative_fetcher) { $derivative_definitions = $derivative_fetcher->getDerivativeDefinitions($plugin_definition); diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php index c7cdb60a4723be5ec045c4a035fd1cdbcdb1a3be..2f4c060b1e63966655d67c8c4c3986359dda561f 100644 --- a/core/lib/Drupal/Core/Condition/ConditionManager.php +++ b/core/lib/Drupal/Core/Condition/ConditionManager.php @@ -23,9 +23,12 @@ class ConditionManager extends PluginManagerBase implements ExecutableManagerInt /** * Constructs aa ConditionManager object. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('Core', 'Condition'); + public function __construct(array $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/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 6f7ff31adfc4e6b0eaa6c0d4723bb597a02192c2..2968e7a0ae1fae464070c694218106104925070e 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -141,7 +141,8 @@ public function build(ContainerBuilder $container) { ->addMethodCall('setUserAgent', array('Drupal (+http://drupal.org/)')); // Register the EntityManager. - $container->register('plugin.manager.entity', 'Drupal\Core\Entity\EntityManager'); + $container->register('plugin.manager.entity', 'Drupal\Core\Entity\EntityManager') + ->addArgument('%container.namespaces%'); // The 'request' scope and service enable services to depend on the Request // object and get reconstructed when the request object changes (e.g., @@ -181,7 +182,8 @@ public function build(ContainerBuilder $container) { ->addArgument('slave'); $container->register('typed_data', 'Drupal\Core\TypedData\TypedDataManager') ->addMethodCall('setValidationConstraintManager', array(new Reference('validation.constraint'))); - $container->register('validation.constraint', 'Drupal\Core\Validation\ConstraintManager'); + $container->register('validation.constraint', 'Drupal\Core\Validation\ConstraintManager') + ->addArgument('%container.namespaces%'); // Add the user's storage for temporary, non-cache data. $container->register('lock', 'Drupal\Core\Lock\DatabaseLockBackend'); diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index d56f5037c86df05925be8a05f863b2c01821c4d3..729ff78d4ac029eaa87e8269068cf7cffd37b07c 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -168,7 +168,7 @@ public function registerBundles() { $module_list = $this->configStorage->read('system.module'); $this->moduleList = isset($module_list['enabled']) ? $module_list['enabled'] : array(); } - $this->registerModuleNamespaces($this->getModuleFileNames()); + $this->registerNamespaces($this->getModuleNamespaces($this->getModuleFileNames())); // Load each module's bundle class. foreach ($this->moduleList as $module => $weight) { @@ -295,7 +295,7 @@ protected function initializeContainer() { // from the container. $container_modules = $this->container->getParameter('container.modules'); $namespaces_before = $this->classLoader->getNamespaces(); - $this->registerModuleNamespaces($container_modules); + $this->registerNamespaces($this->getModuleNamespaces($container_modules)); // If 'container.modules' is wrong, the container must be rebuilt. if (!isset($this->moduleList)) { @@ -368,6 +368,13 @@ protected function buildContainer() { $container = $this->getContainerBuilder(); $container->setParameter('container.bundles', $this->bundleClasses); $container->setParameter('container.modules', $this->getModuleFileNames()); + + // Get a list of namespaces and put it onto the container. + $namespaces = $this->getModuleNamespaces($this->getModuleFileNames()); + $namespaces['Drupal\Core'] = DRUPAL_ROOT . '/core/lib'; + $namespaces['Drupal\Component'] = DRUPAL_ROOT . '/core/lib'; + $container->setParameter('container.namespaces', $namespaces); + // Register synthetic services. $container->register('class_loader', 'Symfony\Component\ClassLoader\UniversalClassLoader')->setSynthetic(TRUE); $container->register('kernel', 'Symfony\Component\HttpKernel\KernelInterface')->setSynthetic(TRUE); @@ -453,11 +460,22 @@ protected function getModuleFileNames() { } /** - * Registers the namespace of each enabled module with the class loader. + * Gets the namespaces of each enabled module. */ - protected function registerModuleNamespaces($moduleFileNames) { + protected function getModuleNamespaces($moduleFileNames) { + $namespaces = array(); foreach ($moduleFileNames as $module => $filename) { - $this->classLoader->registerNamespace("Drupal\\$module", DRUPAL_ROOT . '/' . dirname($filename) . '/lib'); + $namespaces["Drupal\\$module"] = DRUPAL_ROOT . '/' . dirname($filename) . '/lib'; + } + return $namespaces; + } + + /** + * Registers a list of namespaces. + */ + protected function registerNamespaces(array $namespaces = array()) { + foreach ($namespaces as $namespace => $dir) { + $this->classLoader->registerNamespace($namespace, $dir); } } } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 566b2ccf93166ffb7b9832a1f8028e9296b1404f..a0d7c0371b1888460a11f4dd8e7d73a7bc0fd4eb 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -168,10 +168,13 @@ class EntityManager extends PluginManagerBase { /** * Constructs a new Entity plugin manager. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { + public function __construct(array $namespaces) { // Allow the plugin definition to be altered by hook_entity_info_alter(). - $this->discovery = new AnnotatedClassDiscovery('Core', 'Entity'); + $this->discovery = new AnnotatedClassDiscovery('Core', 'Entity', $namespaces); $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info'); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new AlterDecorator($this->discovery, 'entity_info'); @@ -186,12 +189,6 @@ public function __construct() { public function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); - // @todo Remove this check once http://drupal.org/node/1780396 is resolved. - if (!module_exists($definition['module'])) { - $definition = NULL; - return; - } - // Prepare entity schema fields SQL info for // Drupal\Core\Entity\DatabaseStorageControllerInterface::buildQuery(). if (isset($definition['base_table'])) { diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php index 0b387dc7e578031e4652dcedcf2e8d7a49701d56..dca530641d736d856d1de32b6fd0449618587a1c 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -16,32 +16,33 @@ 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 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 + * namespace. + * + * @todo Figure out how to make the following comment FALSE. + * Drupal modules can be enabled (and therefore, namespaces registered) + * during the lifetime of a plugin manager. Passing $root_namespaces into + * the constructor means plugins in the new namespaces will not be available + * until the next request. Additionally when a namespace is unregistered, + * plugins will not be removed until the next request. */ - function __construct($owner, $type, $root_namespaces = NULL) { - $this->owner = $owner; - $this->type = $type; - $this->rootNamespaces = $root_namespaces; + function __construct($owner, $type, array $root_namespaces = array()) { $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'); - } - - /** - * Overrides Drupal\Component\Plugin\Discovery\AnnotatedClassDiscovery::getPluginNamespaces(). - * - * 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() { $plugin_namespaces = array(); - $root_namespaces = isset($this->rootNamespaces) ? $this->rootNamespaces : drupal_classloader()->getNamespaces(); - foreach ($root_namespaces as $namespace => $dirs) { - $plugin_namespaces["$namespace\\Plugin\\{$this->owner}\\{$this->type}"] = $dirs; + foreach ($root_namespaces as $namespace => $dir) { + $plugin_namespaces["$namespace\\Plugin\\{$owner}\\{$type}"] = array($dir); } - return $plugin_namespaces; + parent::__construct($plugin_namespaces, $annotation_namespaces, 'Drupal\Core\Annotation\Plugin'); } } diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index 5177f090b80d7e56f2d53313a3c472d48874c0cb..e0444ae268afb0612e9d009cdeb324394a5a78a3 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -38,9 +38,12 @@ class ConstraintManager extends PluginManagerBase { /** * Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct(). + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('Validation', 'Constraint'); + public function __construct(array $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/aggregator.admin.inc b/core/modules/aggregator/aggregator.admin.inc index f87d9a09d84db9a157c53bac1c011ffc5a8a0dd0..632f1ec0877dba6925d6c29c57d4fd95c52d5869 100644 --- a/core/modules/aggregator/aggregator.admin.inc +++ b/core/modules/aggregator/aggregator.admin.inc @@ -6,7 +6,6 @@ */ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Drupal\aggregator\Plugin\FetcherManager; use Drupal\aggregator\Plugin\Core\Entity\Feed; /** @@ -346,7 +345,7 @@ function aggregator_admin_form($form, $form_state) { aggregator_sanitize_configuration(); // Get all available fetchers. - $fetcher_manager = new FetcherManager(); + $fetcher_manager = drupal_container()->get('plugin.manager.aggregator.fetcher'); $fetchers = array(); foreach ($fetcher_manager->getDefinitions() as $id => $definition) { $label = $definition['title'] . ' ' . $definition['description'] . ''; diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 7298e4ca6225fc340778f82480378d9b338d210b..6e89fdec09fb686614e3ecf39c96680d659436dd 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -5,7 +5,6 @@ * Used to aggregate syndicated content (RSS, RDF, and Atom). */ -use Drupal\aggregator\Plugin\FetcherManager; use Drupal\aggregator\Plugin\Core\Entity\Feed; /** @@ -450,7 +449,7 @@ function aggregator_refresh(Feed $feed) { list($fetcher, $parser, $processors) = _aggregator_get_variables(); // Fetch the feed. - $fetcher_manager = new FetcherManager(); + $fetcher_manager = drupal_container()->get('plugin.manager.aggregator.fetcher'); try { $success = $fetcher_manager->createInstance($fetcher)->fetch($feed); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/AggregatorBundle.php b/core/modules/aggregator/lib/Drupal/aggregator/AggregatorBundle.php new file mode 100644 index 0000000000000000000000000000000000000000..9c97d9a4d6250926e5ebea4bf82dd17a84c96f4a --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/AggregatorBundle.php @@ -0,0 +1,26 @@ +register('plugin.manager.aggregator.fetcher', 'Drupal\aggregator\Plugin\FetcherManager') + ->addArgument('%container.namespaces%'); + } + +} diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/FetcherManager.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/FetcherManager.php index fa63c23b387ddcd2560a72a67ad7a57d89fed293..be8fc79ee29bf486203665f26751b7bfda6bc312 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/FetcherManager.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/FetcherManager.php @@ -17,8 +17,14 @@ */ class FetcherManager extends PluginManagerBase { - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('aggregator', 'fetcher'); + /** + * Constructs a FetcherManager object. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. + */ + public function __construct(array $namespaces) { + $this->discovery = new AnnotatedClassDiscovery('aggregator', 'fetcher', $namespaces); $this->discovery = new CacheDecorator($this->discovery, 'aggregator_fetcher:' . language(LANGUAGE_TYPE_INTERFACE)->langcode); $this->factory = new DefaultFactory($this->discovery); } diff --git a/core/modules/block/lib/Drupal/block/BlockBundle.php b/core/modules/block/lib/Drupal/block/BlockBundle.php index a20d06a8a97285c986b5513917d5121bf075411e..71dfd331bf444e874649d6df75cf32369e95896d 100644 --- a/core/modules/block/lib/Drupal/block/BlockBundle.php +++ b/core/modules/block/lib/Drupal/block/BlockBundle.php @@ -20,7 +20,8 @@ class BlockBundle extends Bundle { */ public function build(ContainerBuilder $container) { // Register the BlockManager class with the dependency injection container. - $container->register('plugin.manager.block', 'Drupal\block\Plugin\Type\BlockManager'); + $container->register('plugin.manager.block', 'Drupal\block\Plugin\Type\BlockManager') + ->addArgument('%container.namespaces%'); } } 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 91951a937e80ef9cfe8fe33f12a7ec981574cd4b..d5dedb9b68cd0d9667db14c9d389b903846eeacd 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -26,9 +26,12 @@ class BlockManager extends PluginManagerBase { /** * Constructs a new \Drupal\block\Plugin\Type\BlockManager object. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('block', 'block'); + public function __construct(array $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, 'cache_block', CacheBackendInterface::CACHE_PERMANENT, array('block')); @@ -37,7 +40,7 @@ public function __construct() { /** * Overrides \Drupal\Component\Plugin\PluginManagerBase::createInstance(). */ - public function createInstance($plugin_id, array $configuration = array(), Block $entity = NULl) { + public function createInstance($plugin_id, array $configuration = array(), Block $entity = NULL) { $plugin_class = DefaultFactory::getPluginClass($plugin_id, $this->discovery); return new $plugin_class($configuration, $plugin_id, $this->discovery, $entity); } diff --git a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php index 740b34964144e4f7fb936e4b21cca1f0db3bcad0..5beb4826814cee0744f9a943c0023f7ed6c53bc1 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php +++ b/core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php @@ -24,7 +24,7 @@ * "module" = @Translation("Modules") * }, * link_title = @Translation("Configure block"), - * manager = "Drupal\block\Plugin\Type\BlockManager", + * manager = "plugin.manager.block", * menu = TRUE, * path = "admin/structure/block/list", * suffix = "add", @@ -46,7 +46,8 @@ public function form($form, &$form_state, $facet = NULL) { // @todo Add an inline comment here. list($plugin, $theme) = explode(':', $this->getPluginId()); $plugin_definition = $this->getDefinition(); - $manager = new $plugin_definition['manager'](); + // @todo Find out how to let the manager be injected into the class. + $manager = drupal_container()->get($plugin_definition['manager']); $plugins = $manager->getDefinitions(); $form['#theme'] = 'system_plugin_ui_form'; $form['theme'] = array( diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php index 57a3a4bad0be17234e39bd05031e1659a95f3bbf..55002418a541731c5cb10093c8b16aa18c2c6b3d 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php @@ -23,10 +23,12 @@ class CKEditorPluginManager extends PluginManagerBase { /** * Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct(). + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('ckeditor', 'plugin'); - $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); + public function __construct(array $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); @@ -141,18 +143,4 @@ public function injectPluginSettingsForm(array &$form, array &$form_state, Edito } } } - - /** - * Overrides Drupal\Component\Plugin\PluginManagerBase::processDefinition(). - */ - public function processDefinition(&$definition, $plugin_id) { - parent::processDefinition($definition, $plugin_id); - - // @todo Remove this check once http://drupal.org/node/1780396 is resolved. - if (!module_exists($definition['module'])) { - $definition = NULL; - return; - } - } - } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/CkeditorBundle.php b/core/modules/ckeditor/lib/Drupal/ckeditor/CkeditorBundle.php index eb8af1291d74002b854fdc719e9aac50f9e2dcb8..151c23ad2405109a7bd454399d3d6ffffbdf1ae0 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/CkeditorBundle.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/CkeditorBundle.php @@ -20,7 +20,8 @@ class CKEditorBundle extends Bundle { * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build(). */ public function build(ContainerBuilder $container) { - $container->register('plugin.manager.ckeditor.plugin', 'Drupal\ckeditor\CKEditorPluginManager'); + $container->register('plugin.manager.ckeditor.plugin', 'Drupal\ckeditor\CKEditorPluginManager') + ->addArgument('%container.namespaces%'); } } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php index fc569107c60bf72daa20e5a1ced5c89557c2c16a..b7383d74fcda4b293a4affdad72bbeb5d06843a4 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php @@ -63,7 +63,7 @@ function setUp() { * Tests the enabling of plugins. */ function testEnabledPlugins() { - $this->manager = new CKEditorPluginManager(); + $this->manager = new CKEditorPluginManager($this->container->getParameter('container.namespaces')); $editor = entity_load('editor', 'filtered_html'); // Case 1: no CKEditor plugins. @@ -77,6 +77,7 @@ function testEnabledPlugins() { // variations of it, to cover all possible ways a plugin can be enabled) and // clear the editor manager's cache so it is picked up. $this->enableModules(array('ckeditor_test')); + $this->manager = new CKEditorPluginManager($this->container->getParameter('container.namespaces')); $this->manager->clearCachedDefinitions(); // Case 2: CKEditor plugins are available. diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php index a71a725452d5a6a6e02a2fb11f88c75fce5013ce..fbfb93b4c769cfd02d9b4f34b204796c47de42e5 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php @@ -64,7 +64,7 @@ function setUp() { $editor->save(); // Create "CKEditor" text editor plugin instance. - $manager = new EditorManager(); + $manager = new EditorManager($this->container->getParameter('container.namespaces')); $this->ckeditor = $manager->createInstance('ckeditor'); } diff --git a/core/modules/edit/lib/Drupal/edit/EditBundle.php b/core/modules/edit/lib/Drupal/edit/EditBundle.php index f64c29b64639dbb208c16df2987a5d0a90bdb5aa..fe5259421e2e08a49adac030b05c4ad441756d91 100644 --- a/core/modules/edit/lib/Drupal/edit/EditBundle.php +++ b/core/modules/edit/lib/Drupal/edit/EditBundle.php @@ -20,7 +20,8 @@ class EditBundle extends Bundle { * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build(). */ public function build(ContainerBuilder $container) { - $container->register('plugin.manager.edit.editor', 'Drupal\edit\Plugin\EditorManager'); + $container->register('plugin.manager.edit.editor', 'Drupal\edit\Plugin\EditorManager') + ->addArgument('%container.namespaces%'); $container->register('access_check.edit.entity_field', 'Drupal\edit\Access\EditEntityFieldAccessCheck') ->addTag('access_check'); diff --git a/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php b/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php index 66876a6cd6ccf2aea48333e764a9f1ece52ad5ab..ce2d650ff665bfc04906e4ee3e380ae3b46f16ed 100644 --- a/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php +++ b/core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php @@ -23,9 +23,12 @@ class EditorManager extends PluginManagerBase { /** * Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct(). + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('edit', 'editor'); + public function __construct(array $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/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php index 199a5257ad37c3d064153f167335c264639c2706..fdddec0f3a8c0fa9e4e6126c97664aeb79abb3a6 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php @@ -40,7 +40,7 @@ public static function getInfo() { function setUp() { parent::setUp(); - $this->editorManager = new EditorManager(); + $this->editorManager = new EditorManager($this->container->getParameter('container.namespaces')); $this->editorSelector = new EditorSelector($this->editorManager); } @@ -108,7 +108,9 @@ function testText() { function testTextWysiwyg() { // Enable edit_test module so that the 'wysiwyg' Create.js PropertyEditor // widget becomes available. - $this->enableModules(array('edit_test'), FALSE); + $this->enableModules(array('edit_test')); + $this->editorManager = new EditorManager($this->container->getParameter('container.namespaces')); + $this->editorSelector = new EditorSelector($this->editorManager); $field_name = 'field_textarea'; $this->createFieldWithInstance( diff --git a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php index 364e4e0dd2b057cf0aec94534b8d8de22b2c98c5..529d535ff21e0b710f2931e8b6c05b5a5ef4ad53 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php @@ -58,7 +58,7 @@ function setUp() { $this->installSchema('field_test', 'test_entity_revision'); - $this->editorManager = new EditorManager(); + $this->editorManager = new EditorManager($this->container->getParameter('container.namespaces')); $this->accessChecker = new MockEditEntityFieldAccessCheck(); $this->editorSelector = new EditorSelector($this->editorManager); $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); @@ -132,7 +132,10 @@ function testEditorWithCustomMetadata() { // Enable edit_test module so that the WYSIWYG Create.js PropertyEditor // widget becomes available. - $this->enableModules(array('edit_test'), FALSE); + $this->enableModules(array('edit_test')); + $this->editorManager = new EditorManager($this->container->getParameter('container.namespaces')); + $this->editorSelector = new EditorSelector($this->editorManager); + $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); // Create a rich text field. $field_name = 'field_rich'; diff --git a/core/modules/editor/lib/Drupal/editor/EditorBundle.php b/core/modules/editor/lib/Drupal/editor/EditorBundle.php index 1e4b86af4e97519df3f42796312796dada72745a..03389983c7d2046a9527c228610a4cca6e697850 100644 --- a/core/modules/editor/lib/Drupal/editor/EditorBundle.php +++ b/core/modules/editor/lib/Drupal/editor/EditorBundle.php @@ -21,7 +21,8 @@ class EditorBundle extends Bundle { public function build(ContainerBuilder $container) { // Register the plugin manager for our plugin type with the dependency // injection container. - $container->register('plugin.manager.editor', 'Drupal\editor\Plugin\EditorManager'); + $container->register('plugin.manager.editor', 'Drupal\editor\Plugin\EditorManager') + ->addArgument('%container.namespaces%'); } } diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php index 74a5eab068df4d5544a201f0b2479944fe08e4ca..c267b5fd35165f6b946293f4512a186a7925b4cd 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php @@ -21,10 +21,12 @@ class EditorManager extends PluginManagerBase { /** * Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct(). + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('editor', 'editor'); - $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); + public function __construct(array $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); @@ -92,17 +94,4 @@ public function getAttachments(array $format_ids) { return $attachments; } - /** - * Overrides Drupal\Component\Plugin\PluginManagerBase::processDefinition(). - */ - public function processDefinition(&$definition, $plugin_id) { - parent::processDefinition($definition, $plugin_id); - - // @todo Remove this check once http://drupal.org/node/1780396 is resolved. - if (!module_exists($definition['module'])) { - $definition = NULL; - return; - } - } - } diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php index 3a83b8ab9a053ab5f632518d74fb5ac483e28d23..567db78f03e900d14f7c3c0e7a7a223cff469a32 100644 --- a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php +++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php @@ -66,7 +66,7 @@ function setUp() { * Tests the configurable text editor manager. */ function testManager() { - $this->editorManager = new EditorManager(); + $this->editorManager = new EditorManager($this->container->getParameter('container.namespaces')); // Case 1: no text editor available: // - listOptions() should return an empty list of options @@ -79,6 +79,7 @@ function testManager() { // Enable the Text Editor Test module, which has the Unicorn Editor and // clear the editor manager's cache so it is picked up. $this->enableModules(array('editor_test')); + $this->editorManager = new EditorManager($this->container->getParameter('container.namespaces')); $this->editorManager->clearCachedDefinitions(); // Case 2: a text editor available. diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceBundle.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceBundle.php index e490441efdd6e933574a5727be7f223cb3a3e1ae..56bd797370567720207c578111c5bb0a04122562 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceBundle.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceBundle.php @@ -21,6 +21,7 @@ class EntityReferenceBundle extends Bundle { public function build(ContainerBuilder $container) { // Register the SelectionPluginManager class with the dependency injection // container. - $container->register('plugin.manager.entity_reference.selection', 'Drupal\entity_reference\Plugin\Type\SelectionPluginManager'); + $container->register('plugin.manager.entity_reference.selection', 'Drupal\entity_reference\Plugin\Type\SelectionPluginManager') + ->addArgument('%container.namespaces%'); } } 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 af91a2dc9b1e21c75ed4d8c498376d1fbe7e9144..db3bd4790f2d7577266db77036c2e59f008c6568 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 @@ -22,9 +22,12 @@ class SelectionPluginManager extends PluginManagerBase { /** * Constructs a SelectionPluginManager object. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->baseDiscovery = new AlterDecorator(new AnnotatedClassDiscovery('entity_reference', 'selection'), 'entity_reference_selection'); + public function __construct($namespaces) { + $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/FieldBundle.php b/core/modules/field/lib/Drupal/field/FieldBundle.php index 7fd0ddf71b5d58949695560fbbe86b2c06c78ed8..b491a9c8c0ba61c47a44a7261c79af1c2dab4aee 100644 --- a/core/modules/field/lib/Drupal/field/FieldBundle.php +++ b/core/modules/field/lib/Drupal/field/FieldBundle.php @@ -20,8 +20,10 @@ class FieldBundle extends Bundle { */ public function build(ContainerBuilder $container) { // Register the plugin managers for our plugin types with the dependency injection container. - $container->register('plugin.manager.field.widget', 'Drupal\field\Plugin\Type\Widget\WidgetPluginManager'); - $container->register('plugin.manager.field.formatter', 'Drupal\field\Plugin\Type\Formatter\FormatterPluginManager'); + $container->register('plugin.manager.field.widget', 'Drupal\field\Plugin\Type\Widget\WidgetPluginManager') + ->addArgument('%container.namespaces%'); + $container->register('plugin.manager.field.formatter', 'Drupal\field\Plugin\Type\Formatter\FormatterPluginManager') + ->addArgument('%container.namespaces%'); } } 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 c935c441ecda69fe570945cd54c7e130abd32fd8..424f2723102424bb13733612c14d26539dd3992d 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 @@ -30,9 +30,12 @@ class FormatterPluginManager extends PluginManagerBase { /** * Constructs a FormatterPluginManager object. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('field', 'formatter'); + public function __construct($namespaces) { + $this->discovery = new AnnotatedClassDiscovery('field', 'formatter', $namespaces); $this->discovery = new FormatterLegacyDiscoveryDecorator($this->discovery); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new AlterDecorator($this->discovery, '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 2d2c6e2cf6a3501e8ca0e46365140802eeef44e6..7014accad302cd12f6e96e35668bf218c981b812 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 @@ -31,9 +31,12 @@ class WidgetPluginManager extends PluginManagerBase { /** * Constructs a WidgetPluginManager object. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('field', 'widget'); + public function __construct($namespaces) { + $this->discovery = new AnnotatedClassDiscovery('field', 'widget', $namespaces); $this->discovery = new WidgetLegacyDiscoveryDecorator($this->discovery); $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); $this->discovery = new AlterDecorator($this->discovery, 'field_widget_info'); diff --git a/core/modules/layout/lib/Drupal/layout/LayoutBundle.php b/core/modules/layout/lib/Drupal/layout/LayoutBundle.php index 59b8513027ec85ff33df10252cd87d5683687b5b..c639da9f228d771b05d708abcc656605aa8c1f9c 100644 --- a/core/modules/layout/lib/Drupal/layout/LayoutBundle.php +++ b/core/modules/layout/lib/Drupal/layout/LayoutBundle.php @@ -20,6 +20,7 @@ class LayoutBundle extends Bundle { */ public function build(ContainerBuilder $container) { // Register the LayoutManager class with the dependency injection container. - $container->register('plugin.manager.layout', 'Drupal\layout\Plugin\Type\LayoutManager'); + $container->register('plugin.manager.layout', 'Drupal\layout\Plugin\Type\LayoutManager') + ->addArgument('%container.namespaces%'); } } 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 191a3171814760d9cc03b1892643aee4447ce61b..0dcb14c1db602d7a2ec715a88279b968e53c8c4f 100644 --- a/core/modules/layout/lib/Drupal/layout/Plugin/Type/LayoutManager.php +++ b/core/modules/layout/lib/Drupal/layout/Plugin/Type/LayoutManager.php @@ -24,10 +24,13 @@ class LayoutManager extends PluginManagerBase { /** * Overrides Drupal\Component\Plugin\PluginManagerBase::__construct(). + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { + public function __construct($namespaces) { // Create layout plugin derivatives from declaratively defined layouts. - $this->discovery = new AnnotatedClassDiscovery('layout', 'layout'); + $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/node/lib/Drupal/node/Tests/Condition/NodeConditionTest.php b/core/modules/node/lib/Drupal/node/Tests/Condition/NodeConditionTest.php index addc5c093f7385e83fc0343b84768ca919516e9c..a8058f7806176bf7ee6fc2d78c41cc0dc52b5cf9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Condition/NodeConditionTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Condition/NodeConditionTest.php @@ -38,7 +38,7 @@ protected function setUp() { * Tests conditions. */ function testConditions() { - $manager = new ConditionManager(); + $manager = new ConditionManager($this->container->getParameter('container.namespaces')); // Get some nodes of various types to check against. $page = entity_create('node', array('type' => 'page', 'title' => $this->randomName())); 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 1bafc062f7049cc60f88c3ec801a7f01b8af064d..ec5e31e1a120fa8d119ab2ea4d6471abad030cd0 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php @@ -19,10 +19,13 @@ class ResourcePluginManager extends PluginManagerBase { /** * Overrides Drupal\Component\Plugin\PluginManagerBase::__construct(). + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { + public function __construct($namespaces) { // Create resource plugin derivatives from declaratively defined resources. - $this->discovery = new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('rest', 'resource')); + $this->discovery = new DerivativeDiscoveryDecorator(new AnnotatedClassDiscovery('rest', 'resource', $namespaces)); $this->factory = new ReflectionFactory($this->discovery); } diff --git a/core/modules/rest/lib/Drupal/rest/RestBundle.php b/core/modules/rest/lib/Drupal/rest/RestBundle.php index 9d9360fc3cc783e40dc46e5363db3774f1bd37e9..49a1169263292560270e0963cf7990c251ecaf61 100644 --- a/core/modules/rest/lib/Drupal/rest/RestBundle.php +++ b/core/modules/rest/lib/Drupal/rest/RestBundle.php @@ -22,7 +22,8 @@ class RestBundle extends Bundle { public function build(ContainerBuilder $container) { // Register the resource manager class with the dependency injection // container. - $container->register('plugin.manager.rest', 'Drupal\rest\Plugin\Type\ResourcePluginManager'); + $container->register('plugin.manager.rest', 'Drupal\rest\Plugin\Type\ResourcePluginManager') + ->addArgument('%container.namespaces%'); $container->register('rest.route_subscriber', 'Drupal\rest\EventSubscriber\RouteSubscriber') ->addArgument(new Reference('plugin.manager.rest')) diff --git a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php index f2c312df77e7ed95d2319175f5cd54856f2deac8..dd890fd48a612ba92e2348162706300921dda9f1 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php +++ b/core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php @@ -22,7 +22,13 @@ abstract class PluginUIBase extends PluginBase implements PluginUIInterface { */ public function form($form, &$form_state) { $plugin_definition = $this->getDefinition(); - $manager = new $plugin_definition['manager'](); + // @todo Find out how to let the manager be injected into the class. + if (class_exists($plugin_definition['manager'])) { + $manager = new $plugin_definition['manager'](); + } + else { + $manager = drupal_container()->get($plugin_definition['manager']); + } $plugins = $manager->getDefinitions(); $rows = array(); 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 069f2b23c21e003a26ba0c16696a4ebdbbd1f9e6..dd7fca3036b2d061732713fb759b77cbc5e59d0e 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php @@ -23,9 +23,12 @@ class PluginUIManager extends PluginManagerBase { /** * Constructs a \Drupal\system\Plugin\Type\PluginUIManager object. + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('system', 'plugin_ui'); + public function __construct($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/SystemBundle.php b/core/modules/system/lib/Drupal/system/SystemBundle.php index 8662169c40768e4892befd3c7a8c9342565cdfd6..2b937c0785c07b3214f5d8b589f8d02272d2774b 100644 --- a/core/modules/system/lib/Drupal/system/SystemBundle.php +++ b/core/modules/system/lib/Drupal/system/SystemBundle.php @@ -24,6 +24,7 @@ public function build(ContainerBuilder $container) { // Register the various system plugin manager classes with the dependency // injection container. - $container->register('plugin.manager.system.plugin_ui', 'Drupal\system\Plugin\Type\PluginUIManager'); + $container->register('plugin.manager.system.plugin_ui', 'Drupal\system\Plugin\Type\PluginUIManager') + ->addArgument('%container.namespaces%'); } } 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 5f395e124a1d7d0405a0a4a15e9e98485b410f9d..fb026e95f168c8470ced8e696f4b5eb1aad6423b 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 @@ -53,8 +53,9 @@ public function setUp() { 'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Orange', ), ); - $this->discovery = new AnnotatedClassDiscovery('plugin_test', 'fruit'); - $this->emptyDiscovery = new AnnotatedClassDiscovery('non_existing_module', 'non_existing_plugin_type'); + $namespaces = 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); } -} +} diff --git a/core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php b/core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php index 35a53255e442f634df01c455f67d3df5d6e3c253..03b918eceb2880d7490101fb4a47c52fac8e5d1a 100644 --- a/core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php +++ b/core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php @@ -33,7 +33,7 @@ public function getFormID() { * Provides a simple method the router can fire in order to invoke this form. */ public function getForm() { - $manager = new ConditionManager(); + $manager = new ConditionManager(drupal_container()->getParameter('container.namespaces')); $this->condition = $manager->createInstance('node_type'); return drupal_get_form($this); } diff --git a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php index 19732c1f2007524642c357c6c23aee143f8430c9..b8603987a8b933fbfc8b78d55e6d8659617d7327 100644 --- a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php +++ b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php @@ -20,10 +20,12 @@ class TipPluginManager extends PluginManagerBase { /** * Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct(). + * + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct() { - $this->discovery = new AnnotatedClassDiscovery('tour', 'tip'); - $this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition')); + public function __construct(array $namespaces) { + $this->discovery = new AnnotatedClassDiscovery('tour', 'tip', $namespaces); $this->discovery = new CacheDecorator($this->discovery, 'tour'); $this->factory = new DefaultFactory($this->discovery); } @@ -37,17 +39,4 @@ public function createInstance($plugin_id, array $configuration = array(), TipsB $plugin_class = DefaultFactory::getPluginClass($plugin_id, $this->discovery); return new $plugin_class($configuration, $plugin_id, $this->discovery, $bag); } - - /** - * Overrides \Drupal\Component\Plugin\PluginManagerBase::processDefinition(). - */ - public function processDefinition(&$definition, $plugin_id) { - parent::processDefinition($definition, $plugin_id); - - // @todo Remove this check once http://drupal.org/node/1780396 is resolved. - if (!module_exists($definition['module'])) { - $definition = NULL; - return; - } - } } diff --git a/core/modules/tour/lib/Drupal/tour/TourBundle.php b/core/modules/tour/lib/Drupal/tour/TourBundle.php index 6839645ae63c91323af9f8677a66c73edb050f03..f1394822446cc5ab269570364898d9a5e6a92c32 100644 --- a/core/modules/tour/lib/Drupal/tour/TourBundle.php +++ b/core/modules/tour/lib/Drupal/tour/TourBundle.php @@ -21,6 +21,7 @@ class TourBundle extends Bundle { public function build(ContainerBuilder $container) { // Register the plugin manager for our plugin type with the dependency // injection container. - $container->register('plugin.manager.tour.tip', 'Drupal\tour\TipPluginManager'); + $container->register('plugin.manager.tour.tip', 'Drupal\tour\TipPluginManager') + ->addArgument('%container.namespaces%'); } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php index 14fc64a72d83b094ce3d1b67bbcb33792541dfbf..56633f847531aaef943bc2474eff483d4f49ab65 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php +++ b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php @@ -22,9 +22,14 @@ class ViewsPluginManager extends PluginManagerBase { /** * Constructs a ViewsPluginManager object. + * + * @param string $type + * The plugin type, for example filter. + * @param array $namespaces + * An array of paths keyed by it's corresponding namespaces. */ - public function __construct($type) { - $this->discovery = new AnnotatedClassDiscovery('views', $type); + public function __construct($type, array $namespaces = array()) { + $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); diff --git a/core/modules/views/lib/Drupal/views/ViewsBundle.php b/core/modules/views/lib/Drupal/views/ViewsBundle.php index ac035cb6d93bd5c844db3175082f407672ed648e..0b18d3f5b685d7e28e9489b64c4eb82f846a02ef 100644 --- a/core/modules/views/lib/Drupal/views/ViewsBundle.php +++ b/core/modules/views/lib/Drupal/views/ViewsBundle.php @@ -23,7 +23,8 @@ class ViewsBundle extends Bundle { public function build(ContainerBuilder $container) { foreach (ViewExecutable::getPluginTypes() as $type) { $container->register("plugin.manager.views.$type", 'Drupal\views\Plugin\ViewsPluginManager') - ->addArgument($type); + ->addArgument($type) + ->addArgument('%container.namespaces%'); } $container