summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2013-02-28 11:24:13 (GMT)
committercatch2013-02-28 11:24:13 (GMT)
commit780b4392973ad76eb40c65bef84d3fb6e64de75f (patch)
treea8f2cf3aad5e4f605fa0874e057d4488fd0c0a7a
parent17f76e227d8045577caaf8c7a8d845d4efb164ab (diff)
Issue #1836008 by dawehner, Berdir, alexpott, katbailey, effulgentsia, EclipseGc: Fixed Remove drupal_classloader() use in Drupal\Core\AnnotatedClassDiscovery.
-rw-r--r--core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php5
-rw-r--r--core/lib/Drupal/Core/Condition/ConditionManager.php7
-rw-r--r--core/lib/Drupal/Core/CoreBundle.php6
-rw-r--r--core/lib/Drupal/Core/DrupalKernel.php28
-rw-r--r--core/lib/Drupal/Core/Entity/EntityManager.php13
-rw-r--r--core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php39
-rw-r--r--core/lib/Drupal/Core/Validation/ConstraintManager.php7
-rw-r--r--core/modules/aggregator/aggregator.admin.inc3
-rw-r--r--core/modules/aggregator/aggregator.module3
-rw-r--r--core/modules/aggregator/lib/Drupal/aggregator/AggregatorBundle.php26
-rw-r--r--core/modules/aggregator/lib/Drupal/aggregator/Plugin/FetcherManager.php10
-rw-r--r--core/modules/block/lib/Drupal/block/BlockBundle.php3
-rw-r--r--core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php9
-rw-r--r--core/modules/block/lib/Drupal/block/Plugin/system/plugin_ui/BlockPluginUI.php5
-rw-r--r--core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php22
-rw-r--r--core/modules/ckeditor/lib/Drupal/ckeditor/CkeditorBundle.php3
-rw-r--r--core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorPluginManagerTest.php3
-rw-r--r--core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorTest.php2
-rw-r--r--core/modules/edit/lib/Drupal/edit/EditBundle.php3
-rw-r--r--core/modules/edit/lib/Drupal/edit/Plugin/EditorManager.php7
-rw-r--r--core/modules/edit/lib/Drupal/edit/Tests/EditorSelectionTest.php6
-rw-r--r--core/modules/edit/lib/Drupal/edit/Tests/MetadataGeneratorTest.php7
-rw-r--r--core/modules/editor/lib/Drupal/editor/EditorBundle.php3
-rw-r--r--core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php21
-rw-r--r--core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php3
-rw-r--r--core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceBundle.php3
-rw-r--r--core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php7
-rw-r--r--core/modules/field/lib/Drupal/field/FieldBundle.php6
-rw-r--r--core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php7
-rw-r--r--core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php7
-rw-r--r--core/modules/layout/lib/Drupal/layout/LayoutBundle.php3
-rw-r--r--core/modules/layout/lib/Drupal/layout/Plugin/Type/LayoutManager.php7
-rw-r--r--core/modules/node/lib/Drupal/node/Tests/Condition/NodeConditionTest.php2
-rw-r--r--core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php7
-rw-r--r--core/modules/rest/lib/Drupal/rest/RestBundle.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Plugin/PluginUIBase.php8
-rw-r--r--core/modules/system/lib/Drupal/system/Plugin/Type/PluginUIManager.php7
-rw-r--r--core/modules/system/lib/Drupal/system/SystemBundle.php3
-rw-r--r--core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php7
-rw-r--r--core/modules/system/tests/modules/condition_test/lib/Drupal/condition_test/FormController.php2
-rw-r--r--core/modules/tour/lib/Drupal/tour/TipPluginManager.php21
-rw-r--r--core/modules/tour/lib/Drupal/tour/TourBundle.php3
-rw-r--r--core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php9
-rw-r--r--core/modules/views/lib/Drupal/views/ViewsBundle.php3
44 files changed, 215 insertions, 144 deletions
diff --git a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
index d7fc8d6..e245874 100644
--- a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
+++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php
@@ -65,11 +65,6 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
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 c7cdb60..2f4c060 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 6f7ff31..2968e7a 100644
--- a/core/lib/Drupal/Core/CoreBundle.php
+++ b/core/lib/Drupal/Core/CoreBundle.php
@@ -141,7 +141,8 @@ class CoreBundle extends Bundle {
->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 @@ class CoreBundle extends Bundle {
->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 d56f503..729ff78 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -168,7 +168,7 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface {
$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 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface {
// 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 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface {
$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 @@ class DrupalKernel extends Kernel implements DrupalKernelInterface {
}
/**
- * 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 566b2cc..a0d7c03 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 @@ class EntityManager extends PluginManagerBase {
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 0b387dc..dca5306 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 5177f09..e0444ae 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 f87d9a0..632f1ec 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'] . ' <span class="description">' . $definition['description'] . '</span>';
diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module
index 7298e4c..6e89fde 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 0000000..9c97d9a
--- /dev/null
+++ b/core/modules/aggregator/lib/Drupal/aggregator/AggregatorBundle.php
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\aggregator\AggregatorBundle.
+ */
+
+namespace Drupal\aggregator;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+/**
+ * Registers aggregator module's services to the container.
+ */
+class AggregatorBundle extends Bundle {
+
+ /**
+ * Overrides Bundle::build().
+ */
+ public function build(ContainerBuilder $container) {
+ $container->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 fa63c23..be8fc79 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 @@ use Drupal\Core\Plugin\Discovery\CacheDecorator;
*/
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 a20d06a..71dfd33 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 91951a9..d5dedb9 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 @@ class BlockManager extends PluginManagerBase {
/**
* 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 740b349..5beb482 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 @@ use Drupal\Core\Annotation\Translation;
* "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 @@ class BlockPluginUI extends PluginUIBase {
// @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 57a3a4b..5500241 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 @@ class CKEditorPluginManager extends PluginManagerBase {
}
}
}
-
- /**
- * 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 eb8af12..151c23a 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 fc56910..b7383d7 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 @@ class CKEditorPluginManagerTest extends DrupalUnitTestBase {
* 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 @@ class CKEditorPluginManagerTest extends DrupalUnitTestBase {
// 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 a71a725..fbfb93b 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 @@ class CKEditorTest extends DrupalUnitTestBase {
$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 f64c29b..fe52594 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 66876a6..ce2d650 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 199a525..fdddec0 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 @@ class EditorSelectionTest extends EditTestBase {
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 @@ class EditorSelectionTest extends EditTestBase {
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 364e4e0..529d535 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 @@ class MetadataGeneratorTest extends EditTestBase {
$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 @@ class MetadataGeneratorTest extends EditTestBase {
// 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 1e4b86a..0338998 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 74a5eab..c267b5f 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 @@ class EditorManager extends PluginManagerBase {
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 3a83b8a..567db78 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 @@ class EditorManagerTest extends DrupalUnitTestBase {
* 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 @@ class EditorManagerTest extends DrupalUnitTestBase {
// 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 e490441..56bd797 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 af91a2d..db3bd47 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 7fd0ddf..b491a9c 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 c935c44..424f272 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 2d2c6e2..7014acc 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 59b8513..c639da9 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 191a317..0dcb14c 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 addc5c0..a8058f7 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 @@ class NodeConditionTest extends DrupalUnitTestBase {
* 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 1bafc06..ec5e31e 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 9d9360f..49a1169 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 f2c312d..dd890fd 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 069f2b2..dd7fca3 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 8662169..2b937c0 100644
--- a/core/modules/system/lib/Drupal/system/SystemBundle.php
+++ b/core/modules/system/lib/Drupal/system/SystemBundle.php
@@ -24,6 +24,7 @@ class SystemBundle extends Bundle {
// 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 5f395e1..fb026e9 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 @@ class AnnotatedClassDiscoveryTest extends DiscoveryTestBase {
'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 35a5325..03b918e 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 @@ class FormController implements FormInterface {
* 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 19732c1..b860398 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 @@ class TipPluginManager extends PluginManagerBase {
$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 6839645..f139482 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 14fc64a..56633f8 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 ac035cb..0b18d3f 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