Issue #1836008 by dawehner, Berdir, alexpott, katbailey, effulgentsia, EclipseGc: Fixed Remove drupal_classloader() use in Drupal\Core\AnnotatedClassDiscovery.
parent
17f76e227d
commit
780b439297
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'])) {
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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>';
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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'));
|
||||
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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%');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue