diff --git a/core/core.services.yml b/core/core.services.yml index d2de794128788bc4aacb1a82cb5669d068df520a..317af02b89a3ade3a90fb24df0c79d1f019bfc01 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -605,7 +605,7 @@ services: - { name: event_subscriber } image.toolkit.manager: class: Drupal\Core\ImageToolkit\ImageToolkitManager - arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@config.factory'] + arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@config.factory', '@module_handler'] image.toolkit: class: Drupal\Core\ImageToolkit\ImageToolkitInterface factory_method: getDefaultToolkit diff --git a/core/lib/Drupal/Core/Archiver/ArchiverManager.php b/core/lib/Drupal/Core/Archiver/ArchiverManager.php index f446f37a72d37d6a149609f3ff6d87bc5055cf74..e45fc875aaedd1f9843c99ac14e75509050e6d80 100644 --- a/core/lib/Drupal/Core/Archiver/ArchiverManager.php +++ b/core/lib/Drupal/Core/Archiver/ArchiverManager.php @@ -31,8 +31,8 @@ class ArchiverManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/Archiver', $namespaces, 'Drupal\Core\Archiver\Annotation\Archiver'); - $this->alterInfo($module_handler, 'archiver_info'); + parent::__construct('Plugin/Archiver', $namespaces, $module_handler, 'Drupal\Core\Archiver\Annotation\Archiver'); + $this->alterInfo('archiver_info'); $this->setCacheBackend($cache_backend, $language_manager, 'archiver_info_plugins'); } diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php index 604fea4f15fe471b726fce469de4e76f94b00e5f..4b4e6599d6d0249f03650dbf6c6cf86068ac5ca4 100644 --- a/core/lib/Drupal/Core/Condition/ConditionManager.php +++ b/core/lib/Drupal/Core/Condition/ConditionManager.php @@ -33,10 +33,10 @@ class ConditionManager extends DefaultPluginManager implements ExecutableManager * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - $this->alterInfo($module_handler, 'condition_info'); + $this->alterInfo('condition_info'); $this->setCacheBackend($cache_backend, $language_manager, 'condition_plugins'); - parent::__construct('Plugin/Condition', $namespaces, 'Drupal\Core\Condition\Annotation\Condition'); + parent::__construct('Plugin/Condition', $namespaces, $module_handler, 'Drupal\Core\Condition\Annotation\Condition'); } /** diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php index 75ea2fd4b0b778fb7e8b833d671068138c5a5096..3a41a5e6f476b106eff0c30ca32c05e629c85d4c 100644 --- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php @@ -41,8 +41,8 @@ class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePl * The module handler. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/Field/FieldType', $namespaces, 'Drupal\Core\Field\Annotation\FieldType'); - $this->alterInfo($module_handler, 'field_info'); + parent::__construct('Plugin/Field/FieldType', $namespaces, $module_handler, 'Drupal\Core\Field\Annotation\FieldType'); + $this->alterInfo('field_info'); $this->setCacheBackend($cache_backend, $language_manager, 'field_types_plugins'); } diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index c30ab0ea419de69b16894965f015ec71e5c43b16..8d3781829a1d7b4e7163bbc4199568d7bea363be 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -49,10 +49,10 @@ class FormatterPluginManager extends DefaultPluginManager { */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager, FieldTypePluginManagerInterface $field_type_manager) { - parent::__construct('Plugin/Field/FieldFormatter', $namespaces, 'Drupal\Core\Field\Annotation\FieldFormatter'); + parent::__construct('Plugin/Field/FieldFormatter', $namespaces, $module_handler, 'Drupal\Core\Field\Annotation\FieldFormatter'); $this->setCacheBackend($cache_backend, $language_manager, 'field_formatter_types_plugins'); - $this->alterInfo($module_handler, 'field_formatter_info'); + $this->alterInfo('field_formatter_info'); $this->fieldTypeManager = $field_type_manager; } diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php index 5ca455a0e7eb1b690b0156282f83e223bb49a50c..47fedb14083bd5ff19f15d4fd57c97245a159b1f 100644 --- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php +++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php @@ -48,10 +48,10 @@ class WidgetPluginManager extends DefaultPluginManager { * The 'field type' plugin manager. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager, FieldTypePluginManagerInterface $field_type_manager) { - parent::__construct('Plugin/Field/FieldWidget', $namespaces, 'Drupal\Core\Field\Annotation\FieldWidget'); + parent::__construct('Plugin/Field/FieldWidget', $namespaces, $module_handler, 'Drupal\Core\Field\Annotation\FieldWidget'); $this->setCacheBackend($cache_backend, $language_manager, 'field_widget_types_plugins'); - $this->alterInfo($module_handler, 'field_widget_info'); + $this->alterInfo('field_widget_info'); $this->factory = new WidgetFactory($this); $this->fieldTypeManager = $field_type_manager; diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php index eceab87976d9aa1466f0ec67c9f3097032d28458..5ec45ea54c2840a9bd34842131bff75aff03c0ee 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php @@ -9,6 +9,7 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Plugin\DefaultPluginManager; @@ -36,9 +37,11 @@ class ImageToolkitManager extends DefaultPluginManager { * The language manager. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. */ - public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ConfigFactoryInterface $config_factory) { - parent::__construct('Plugin/ImageToolkit', $namespaces, 'Drupal\Core\ImageToolkit\Annotation\ImageToolkit'); + public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) { + parent::__construct('Plugin/ImageToolkit', $namespaces, $module_handler, 'Drupal\Core\ImageToolkit\Annotation\ImageToolkit'); $this->setCacheBackend($cache_backend, $language_manager, 'image_toolkit_plugins'); $this->configFactory = $config_factory; diff --git a/core/lib/Drupal/Core/Mail/MailManager.php b/core/lib/Drupal/Core/Mail/MailManager.php index 9f012813591b7f7e8647bfb06df128a7da0875b3..3fe58f1c5382df83f259393356282ff7df5d4475 100644 --- a/core/lib/Drupal/Core/Mail/MailManager.php +++ b/core/lib/Drupal/Core/Mail/MailManager.php @@ -50,8 +50,8 @@ class MailManager extends DefaultPluginManager { * The configuration factory. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) { - parent::__construct('Plugin/Mail', $namespaces, 'Drupal\Core\Annotation\Mail'); - $this->alterInfo($module_handler, 'mail_backend_info'); + parent::__construct('Plugin/Mail', $namespaces, $module_handler, 'Drupal\Core\Annotation\Mail'); + $this->alterInfo('mail_backend_info'); $this->setCacheBackend($cache_backend, $language_manager, 'mail_backend_plugins'); $this->mailConfig = $config_factory->get('system.mail'); } diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php index 5141f5c233a2ffba93e3dd8325baf00aee967d06..c585b00f5f1019b9b023455dc92e6699c8abd6fe 100644 --- a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php @@ -100,7 +100,8 @@ public function __construct(ControllerResolverInterface $controller_resolver, Mo $this->controllerResolver = $controller_resolver; $this->accessManager = $access_manager; $this->account = $account; - $this->alterInfo($module_handler, 'contextual_links_plugins'); + $this->moduleHandler = $module_handler; + $this->alterInfo('contextual_links_plugins'); $this->setCacheBackend($cache_backend, $language_manager, 'contextual_links_plugins'); } diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php index 79e40c9f365891017e20d25d8d406900dc4c76c3..457af4f917c0e1af198d69fe88b7c7f6b3ce509a 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionManager.php +++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php @@ -128,12 +128,12 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re $this->factory = new ContainerFactory($this); $this->routeProvider = $route_provider; $this->accessManager = $access_manager; + $this->moduleHandler = $module_handler; $this->account = $account; $this->controllerResolver = $controller_resolver; $this->request = $request; - $this->alterInfo($module_handler, 'menu_local_actions'); + $this->alterInfo('menu_local_actions'); $this->setCacheBackend($cache_backend, $language_manager, 'local_action_plugins', array('local_action' => TRUE)); - } /** diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index fde294fdd3393cd20fb852212492581b73f1561f..5f954d1dab28175f0331509301c8524be2f024cf 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -137,7 +137,8 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re $this->routeBuilder = $route_builder; $this->accessManager = $access_manager; $this->account = $account; - $this->alterInfo($module_handler, 'local_tasks'); + $this->moduleHandler = $module_handler; + $this->alterInfo('local_tasks'); $this->setCacheBackend($cache, $language_manager, 'local_task_plugins', array('local_task' => TRUE)); } diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index 6cbabf8989c4420d4df59face99563a459c9c6e6..99abd8944db61882122e68e37a72dd097976d545 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -106,15 +106,18 @@ class DefaultPluginManager extends PluginManagerBase implements PluginManagerInt * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths * keyed by the corresponding namespace to look for plugin implementations. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. * @param string $plugin_definition_annotation_name * (optional) The name of the annotation that contains the plugin definition. * Defaults to 'Drupal\Component\Annotation\Plugin'. */ - public function __construct($subdir, \Traversable $namespaces, $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') { + public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInterface $module_handler, $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin') { $this->subdir = $subdir; $this->discovery = new AnnotatedClassDiscovery($subdir, $namespaces, $plugin_definition_annotation_name); $this->discovery = new ContainerDerivativeDiscoveryDecorator($this->discovery); $this->factory = new ContainerFactory($this); + $this->moduleHandler = $module_handler; } /** @@ -150,13 +153,10 @@ public function setCacheBackend(CacheBackendInterface $cache_backend, LanguageMa /** * Initializes the alter hook. * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke the alter hook with. * @param string $alter_hook * Name of the alter hook. */ - protected function alterInfo(ModuleHandlerInterface $module_handler, $alter_hook) { - $this->moduleHandler = $module_handler; + protected function alterInfo($alter_hook) { $this->alterHook = $alter_hook; } @@ -267,6 +267,13 @@ protected function findDefinitions() { if ($this->alterHook) { $this->moduleHandler->alter($this->alterHook, $definitions); } + // If this plugin was provided by a module that does not exist, remove the + // plugin definition. + foreach ($definitions as $plugin_id => $plugin_definition) { + if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('Core', 'Component')) && !$this->moduleHandler->moduleExists($plugin_definition['provider'])) { + unset($definitions[$plugin_id]); + } + } return $definitions; } diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index f8c9ab4f398a2d7604c6293c922b265c6c296098..ff77acb66226ec2b71349b7d69a5c8804e381d84 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -45,11 +45,24 @@ class TypedDataManager extends DefaultPluginManager { */ protected $prototypes = array(); + /** + * Constructs a new TypedDataManager. + * + * @param \Traversable $namespaces + * An object that implements \Traversable which contains the root paths + * keyed by the corresponding namespace to look for plugin implementations. + * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend + * Cache backend instance to use. + * @param \Drupal\Core\Language\LanguageManager $language_manager + * The language manager. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - $this->alterInfo($module_handler, 'data_type_info'); + $this->alterInfo('data_type_info'); $this->setCacheBackend($cache_backend, $language_manager, 'typed_data_types_plugins'); - parent::__construct('Plugin/DataType', $namespaces, 'Drupal\Core\TypedData\Annotation\DataType'); + parent::__construct('Plugin/DataType', $namespaces, $module_handler, 'Drupal\Core\TypedData\Annotation\DataType'); } /** diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index d2e84c7e827d372b54004bc07f7856e70ed40198..54d2b4f8a8963325977aa0b15e44f061c71bce98 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -47,9 +47,9 @@ class ConstraintManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/Validation/Constraint', $namespaces); + parent::__construct('Plugin/Validation/Constraint', $namespaces, $module_handler); $this->discovery = new StaticDiscoveryDecorator($this->discovery, array($this, 'registerDefinitions')); - $this->alterInfo($module_handler, 'validation_constraint'); + $this->alterInfo('validation_constraint'); $this->setCacheBackend($cache_backend, $language_manager, 'validation_constraint_plugins'); } diff --git a/core/modules/aggregator/aggregator.services.yml b/core/modules/aggregator/aggregator.services.yml index e486b54d2698eabb2175ea6544009aa636e77728..335ed77d8649080ad41987a656832125c640a8a9 100644 --- a/core/modules/aggregator/aggregator.services.yml +++ b/core/modules/aggregator/aggregator.services.yml @@ -1,10 +1,10 @@ services: plugin.manager.aggregator.fetcher: class: Drupal\aggregator\Plugin\AggregatorPluginManager - arguments: [fetcher, '@container.namespaces', '@cache.cache', '@language_manager'] + arguments: [fetcher, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] plugin.manager.aggregator.parser: class: Drupal\aggregator\Plugin\AggregatorPluginManager - arguments: [parser, '@container.namespaces', '@cache.cache', '@language_manager'] + arguments: [parser, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] plugin.manager.aggregator.processor: class: Drupal\aggregator\Plugin\AggregatorPluginManager - arguments: [processor, '@container.namespaces', '@cache.cache', '@language_manager'] + arguments: [processor, '@container.namespaces', '@cache.cache', '@language_manager', '@module_handler'] diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php index 5f65c98a57c75213bd23272eddf0d25aab767466..717d41c3fe86b00683c990a1bd86d21889bac392 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php @@ -8,6 +8,7 @@ namespace Drupal\aggregator\Plugin; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManager; use Drupal\Core\Plugin\DefaultPluginManager; @@ -28,15 +29,17 @@ class AggregatorPluginManager extends DefaultPluginManager { * Cache backend instance to use. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. */ - public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager) { + public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { $type_annotations = array( 'fetcher' => 'Drupal\aggregator\Annotation\AggregatorFetcher', 'parser' => 'Drupal\aggregator\Annotation\AggregatorParser', 'processor' => 'Drupal\aggregator\Annotation\AggregatorProcessor', ); - parent::__construct("Plugin/aggregator/$type", $namespaces, $type_annotations[$type]); + parent::__construct("Plugin/aggregator/$type", $namespaces, $module_handler, $type_annotations[$type]); $this->setCacheBackend($cache_backend, $language_manager, 'aggregator_' . $type . '_plugins'); } 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 a1187a697b6b928089aba7d48ffc07588c3dd456..980a59f0178b6f8a713410af16dc9759300e9977 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php @@ -52,9 +52,9 @@ class BlockManager extends DefaultPluginManager { * The translation manager. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler, TranslationInterface $translation_manager) { - parent::__construct('Plugin/Block', $namespaces, 'Drupal\block\Annotation\Block'); + parent::__construct('Plugin/Block', $namespaces, $module_handler, 'Drupal\block\Annotation\Block'); - $this->alterInfo($module_handler, 'block'); + $this->alterInfo('block'); $this->setCacheBackend($cache_backend, $language_manager, 'block_plugins'); $this->translationManager = $translation_manager; } diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php index ffd401b27d8ce4df5efa33d5fcb0802534c771dc..7cc3b19ccaeba6e7ff1a7950fc0c13f371648bad 100644 --- a/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php +++ b/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php @@ -33,8 +33,8 @@ class CKEditorPluginManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/CKEditorPlugin', $namespaces, 'Drupal\ckeditor\Annotation\CKEditorPlugin'); - $this->alterInfo($module_handler, 'ckeditor_plugin_info'); + parent::__construct('Plugin/CKEditorPlugin', $namespaces, $module_handler, 'Drupal\ckeditor\Annotation\CKEditorPlugin'); + $this->alterInfo('ckeditor_plugin_info'); $this->setCacheBackend($cache_backend, $language_manager, 'ckeditor_plugins'); } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php index 7168d2674450a1ef67332379e23df0f18bb07112..0cbcba42176d0166613d88f8c6bfa91e44d82f40 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php @@ -34,6 +34,13 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa */ protected $typedConfigManager; + /** + * The theme handler. + * + * @var \Drupal\Core\Extension\ThemeHandlerInterface + */ + protected $themeHandler; + /** * {@inheritdoc} */ @@ -77,7 +84,10 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage $this->factory = new ContainerFactory($this); // Let others alter definitions with hook_config_translation_info_alter(). - $this->alterInfo($module_handler, 'config_translation_info'); + $this->moduleHandler = $module_handler; + $this->themeHandler = $theme_handler; + + $this->alterInfo('config_translation_info'); $this->setCacheBackend($cache_backend, $language_manager, 'config_translation_info_plugins'); } @@ -104,6 +114,28 @@ public function processDefinition(&$definition, $plugin_id) { } } + /** + * {@inheritdoc} + */ + protected function findDefinitions() { + $definitions = $this->discovery->getDefinitions(); + foreach ($definitions as $plugin_id => &$definition) { + $this->processDefinition($definition, $plugin_id); + } + if ($this->alterHook) { + $this->moduleHandler->alter($this->alterHook, $definitions); + } + + // If this plugin was provided by a module that does not exist, remove the + // plugin definition. + foreach ($definitions as $plugin_id => $plugin_definition) { + if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('Core', 'Component')) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) { + unset($definitions[$plugin_id]); + } + } + return $definitions; + } + /** * {@inheritdoc} */ diff --git a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php index 19b4013ec1265973353b2508be77b965d0506597..85aa79dc9cdba7c3f3c3b7962c06a9a2c06dbcfe 100644 --- a/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php +++ b/core/modules/editor/lib/Drupal/editor/Plugin/EditorManager.php @@ -31,8 +31,8 @@ class EditorManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/Editor', $namespaces, 'Drupal\editor\Annotation\Editor'); - $this->alterInfo($module_handler, 'editor_info'); + parent::__construct('Plugin/Editor', $namespaces, $module_handler, 'Drupal\editor\Annotation\Editor'); + $this->alterInfo('editor_info'); $this->setCacheBackend($cache_backend, $language_manager, 'editor_plugins'); } 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 8f3738414cf1348a4ec5bedf7153e76d11979d49..6ca37c91735953714fdeecf2a023af447d097ffc 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 @@ -33,7 +33,8 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac // method and don't need the derivative discovery decorator. $this->factory = new ReflectionFactory($this); - $this->alterInfo($module_handler, 'entity_reference_selection'); + $this->moduleHandler = $module_handler; + $this->alterInfo('entity_reference_selection'); $this->setCacheBackend($cache_backend, $language_manager, 'entity_reference_selection_plugins'); } diff --git a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php index 1a1fcc033da63649135f312de9f20cff06c7c34f..2be9e4afb623d5baf9863b86aaa475f489618a16 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php +++ b/core/modules/filter/lib/Drupal/filter/FilterPluginManager.php @@ -39,8 +39,8 @@ class FilterPluginManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/Filter', $namespaces, 'Drupal\filter\Annotation\Filter'); - $this->alterInfo($module_handler, 'filter_info'); + parent::__construct('Plugin/Filter', $namespaces, $module_handler, 'Drupal\filter\Annotation\Filter'); + $this->alterInfo('filter_info'); $this->setCacheBackend($cache_backend, $language_manager, 'filter_plugins', array('filter_formats' => TRUE)); } diff --git a/core/modules/image/lib/Drupal/image/ImageEffectManager.php b/core/modules/image/lib/Drupal/image/ImageEffectManager.php index 78ab18bddefcbcedc2976ba6080eba874f39379a..f025c76d5a12d8b93ff81f80e6836fb8841377fc 100644 --- a/core/modules/image/lib/Drupal/image/ImageEffectManager.php +++ b/core/modules/image/lib/Drupal/image/ImageEffectManager.php @@ -18,12 +18,22 @@ class ImageEffectManager extends DefaultPluginManager { /** - * {@inheritdoc} + * Constructs a new ImageEffectManager. + * + * @param \Traversable $namespaces + * An object that implements \Traversable which contains the root paths + * keyed by the corresponding namespace to look for plugin implementations. + * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend + * Cache backend instance to use. + * @param \Drupal\Core\Language\LanguageManager $language_manager + * The language manager. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/ImageEffect', $namespaces, 'Drupal\image\Annotation\ImageEffect'); + parent::__construct('Plugin/ImageEffect', $namespaces, $module_handler, 'Drupal\image\Annotation\ImageEffect'); - $this->alterInfo($module_handler, 'image_effect_info'); + $this->alterInfo('image_effect_info'); $this->setCacheBackend($cache_backend, $language_manager, 'image_effect_plugins'); } diff --git a/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodManager.php b/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodManager.php index 1480bd6ac9bd1d35e518ea8a6a6c919d02c9d608..681c67cd9a7a71777691c4120d8dbbc3d6f06bfa 100644 --- a/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodManager.php +++ b/core/modules/language/lib/Drupal/language/LanguageNegotiationMethodManager.php @@ -28,11 +28,11 @@ class LanguageNegotiationMethodManager extends DefaultPluginManager { * An object that implements ModuleHandlerInterface */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/LanguageNegotiation', $namespaces); + parent::__construct('Plugin/LanguageNegotiation', $namespaces, $module_handler); $this->cacheBackend = $cache_backend; $this->cacheKeyPrefix = 'language_negotiation_plugins'; $this->cacheKey = 'language_negotiation_plugins'; - $this->alterInfo($module_handler, 'language_negotiation_info'); + $this->alterInfo('language_negotiation_info'); } } diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/MigratePluginManager.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/MigratePluginManager.php index 14692cdf69aef1c9bf6e6120858d6920cbf1d571..2fa236d741050a9134c908ec087c22c6c385d20b 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/MigratePluginManager.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/MigratePluginManager.php @@ -39,8 +39,8 @@ class MigratePluginManager extends DefaultPluginManager { * The annotation class name. */ public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler, $annotation = 'Drupal\Component\Annotation\PluginID') { - parent::__construct("Plugin/migrate/$type", $namespaces, $annotation); - $this->alterInfo($module_handler, 'migrate_' . $type . '_info'); + parent::__construct("Plugin/migrate/$type", $namespaces, $module_handler, $annotation); + $this->alterInfo('migrate_' . $type . '_info'); $this->setCacheBackend($cache_backend, $language_manager, 'migrate_plugins_' . $type); } 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 6ff5a349c26b0367c8e8d2f4e27a1cf97a64f018..64630ea03e85770dbd8a5dac6376a68c7efe305d 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php @@ -31,10 +31,10 @@ class ResourcePluginManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/rest/resource', $namespaces, 'Drupal\rest\Annotation\RestResource'); + parent::__construct('Plugin/rest/resource', $namespaces, $module_handler, 'Drupal\rest\Annotation\RestResource'); $this->setCacheBackend($cache_backend, $language_manager, 'rest_plugins'); - $this->alterInfo($module_handler, 'rest_resource'); + $this->alterInfo('rest_resource'); } /** diff --git a/core/modules/search/lib/Drupal/search/SearchPluginManager.php b/core/modules/search/lib/Drupal/search/SearchPluginManager.php index 56075d352a6960fb4b9bd7d476bd2e13b3d7087a..46418996789eadee1ea49d30a21ff57365243134 100644 --- a/core/modules/search/lib/Drupal/search/SearchPluginManager.php +++ b/core/modules/search/lib/Drupal/search/SearchPluginManager.php @@ -31,7 +31,7 @@ class SearchPluginManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/Search', $namespaces, 'Drupal\search\Annotation\SearchPlugin'); + parent::__construct('Plugin/Search', $namespaces, $module_handler, 'Drupal\search\Annotation\SearchPlugin'); $this->setCacheBackend($cache_backend, $language_manager, 'search_plugins'); // @todo Set an alter hook. diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php index 667d95464bc3c7081b804efb79280523b852846f..50d573639c4a9bcc859f7e273f4283f1bfc2b3b5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php @@ -11,6 +11,7 @@ use Drupal\plugin_test\Plugin\TestPluginManager; use Drupal\plugin_test\Plugin\MockBlockManager; use Drupal\plugin_test\Plugin\DefaultsTestPluginManager; +use Drupal\Core\Extension\ModuleHandler; /** * Base class for Plugin API unit tests. @@ -36,7 +37,8 @@ public function setUp() { // as derivatives and ReflectionFactory. $this->testPluginManager = new TestPluginManager(); $this->mockBlockManager = new MockBlockManager(); - $this->defaultsTestPluginManager = new DefaultsTestPluginManager(); + $module_handler = new ModuleHandler(); + $this->defaultsTestPluginManager = new DefaultsTestPluginManager($module_handler); // The expected plugin definitions within each manager. Several tests assert // that these plugins and their definitions are found and returned by the diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/DefaultsTestPluginManager.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/DefaultsTestPluginManager.php index 8ca31653db137002b0f8bd58b5de5f7a26beed9c..e81c39e99caf6a379666b23a89481affad09a6b4 100644 --- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/DefaultsTestPluginManager.php +++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/DefaultsTestPluginManager.php @@ -9,6 +9,7 @@ use Drupal\Component\Plugin\Discovery\StaticDiscovery; use Drupal\Component\Plugin\Factory\DefaultFactory; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; /** @@ -16,13 +17,20 @@ */ class DefaultsTestPluginManager extends DefaultPluginManager { - public function __construct() { + /** + * Constructs a new DefaultsTestPluginManager instance. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + */ + public function __construct(ModuleHandlerInterface $module_handler) { // Create the object that can be used to return definitions for all the // plugins available for this type. Most real plugin managers use a richer // discovery implementation, but StaticDiscovery lets us add some simple // mock plugins for unit testing. $this->discovery = new StaticDiscovery(); $this->factory = new DefaultFactory($this); + $this->moduleHandler = $module_handler; // Specify default values. $this->defaults = array( diff --git a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php index 67dba71ded1f8d745e5fa97750c9fe58587c53b5..32cf923357e46a6c5652a5cecbac9c0df754e001 100644 --- a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php +++ b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php @@ -31,9 +31,9 @@ class TipPluginManager extends DefaultPluginManager { * The module handler to invoke the alter hook with. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/tour/tip', $namespaces, 'Drupal\tour\Annotation\Tip'); + parent::__construct('Plugin/tour/tip', $namespaces, $module_handler, 'Drupal\tour\Annotation\Tip'); - $this->alterInfo($module_handler, 'tour_tips_info'); + $this->alterInfo('tour_tips_info'); $this->setCacheBackend($cache_backend, $language_manager, 'tour_plugins'); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php index b5860548b4a9c153ebb3c999a21b494400e2f085..bcf2c857355b8974162e1daf0365415556d54bc5 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php +++ b/core/modules/views/lib/Drupal/views/Plugin/ViewsPluginManager.php @@ -35,7 +35,7 @@ class ViewsPluginManager extends DefaultPluginManager { */ public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) { $plugin_definition_annotation_name = 'Drupal\views\Annotation\Views' . Container::camelize($type); - parent::__construct("Plugin/views/$type", $namespaces, $plugin_definition_annotation_name); + parent::__construct("Plugin/views/$type", $namespaces, $module_handler, $plugin_definition_annotation_name); $this->defaults += array( 'parent' => 'parent', @@ -43,7 +43,7 @@ public function __construct($type, \Traversable $namespaces, CacheBackendInterfa 'register_theme' => TRUE, ); - $this->alterInfo($module_handler, 'views_plugins_' . $type); + $this->alterInfo('views_plugins_' . $type); $this->setCacheBackend($cache_backend, $language_manager, 'views_' . $type . '_plugins'); } diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php index 49ab1f83c9b824caefa0215ae7e556c3ae183b19..d6fbff297a768dcfdff17b1af76e7e3bbcc58469 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerUnitTest.php @@ -7,10 +7,6 @@ namespace Drupal\Tests\Core\Extension; -if (!defined('DRUPAL_ROOT')) { - define('DRUPAL_ROOT', dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))))); -} - use Drupal\Core\Extension\ModuleHandler; use Drupal\Tests\UnitTestCase; use PHPUnit_Framework_Error_Notice; diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php index 0e52b9f5988aea646729671d7c6a8c2df24ae70f..3f43002bfbce7f9ad7785112e893945e0393c15c 100644 --- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php @@ -88,6 +88,7 @@ protected function setUp() { $this->pluginDiscovery = $this->getMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface'); $this->factory = $this->getMock('Drupal\Component\Plugin\Factory\FactoryInterface'); $this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); + $this->moduleHandler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface'); $this->accessManager = $this->getMockBuilder('Drupal\Core\Access\AccessManager') ->disableOriginalConstructor() ->getMock(); @@ -113,16 +114,18 @@ protected function setUp() { $property->setAccessible(TRUE); $property->setValue($this->contextualLinkManager, $this->accessManager); + $property = new \ReflectionProperty('Drupal\Core\Menu\ContextualLinkManager', 'moduleHandler'); + $property->setAccessible(TRUE); + $property->setValue($this->contextualLinkManager, $this->moduleHandler); + $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->any()) ->method('getCurrentLanguage') ->will($this->returnValue(new Language(array('id' => 'en')))); - $this->moduleHandler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface'); - $method = new \ReflectionMethod('Drupal\Core\Menu\ContextualLinkManager', 'alterInfo'); $method->setAccessible(TRUE); - $method->invoke($this->contextualLinkManager, $this->moduleHandler, 'contextual_links_plugins'); + $method->invoke($this->contextualLinkManager, 'contextual_links_plugins'); $this->contextualLinkManager->setCacheBackend($this->cacheBackend, $language_manager, 'contextual_links_plugins'); } diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php index 6685b9c8d641a4644e0055e4c61dd9583e2491c4..9453d9ceb40a8161f09ac11521f2bc69bd6d9fb7 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php @@ -379,7 +379,8 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re $this->account = $account; $this->controllerResolver = $controller_resolver; $this->request = $request; - $this->alterInfo($module_handler, 'menu_local_actions'); + $this->moduleHandler = $module_handler; + $this->alterInfo('menu_local_actions'); $this->setCacheBackend($cache_backend, $language_manager, 'local_action_plugins', array('local_action' => TRUE)); } diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php index f8dea85349d471a03895d4ad5dd66112120828d2..9106f77d6b6aaa0a0730e4fa0e1ab129ead016c4 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTest.php @@ -83,9 +83,18 @@ protected function getLocalTaskManager($module_dirs, $route_name, $route_params) $property->setAccessible(TRUE); $property->setValue($manager, $route_builder); - $this->moduleHandler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface') + $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface') ->disableOriginalConstructor() ->getMock(); + $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'moduleHandler'); + $property->setAccessible(TRUE); + $property->setValue($manager, $module_handler); + // Set all the modules as being existant. + $module_handler->expects($this->any()) + ->method('moduleExists') + ->will($this->returnCallback(function ($module) use ($module_dirs) { + return isset($module_dirs[$module]); + })); $pluginDiscovery = new YamlDiscovery('local_tasks', $module_dirs); $pluginDiscovery = new ContainerDerivativeDiscoveryDecorator($pluginDiscovery); @@ -95,7 +104,7 @@ protected function getLocalTaskManager($module_dirs, $route_name, $route_params) $method = new \ReflectionMethod('Drupal\Core\Menu\LocalTaskManager', 'alterInfo'); $method->setAccessible(TRUE); - $method->invoke($manager, $this->moduleHandler, 'local_tasks'); + $method->invoke($manager, 'local_tasks'); $plugin_stub = $this->getMock('Drupal\Core\Menu\LocalTaskInterface'); $factory = $this->getMock('Drupal\Component\Plugin\Factory\FactoryInterface'); diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index 894a6e18e58c6954a1c18b8cf022490eeae8d6eb..bd1efc27f1524bf2ed4b7888efdbba1dc547a0ce 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -67,6 +67,31 @@ protected function setUp() { $this->namespaces = new \ArrayObject(array('Drupal\plugin_test' => DRUPAL_ROOT . '/core/modules/system/tests/modules/plugin_test/lib')); } + /** + * Tests the plugin manager with a disabled module. + */ + public function testDefaultPluginManagerWithDisabledModule() { + $definitions = $this->expectedDefinitions; + $definitions['cherry'] = array( + 'id' => 'cherry', + 'label' => 'Cherry', + 'color' => 'red', + 'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Cherry', + 'provider' => 'disabled_module', + ); + + $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); + + $module_handler->expects($this->once()) + ->method('moduleExists') + ->with('disabled_module') + ->will($this->returnValue(FALSE)); + + $plugin_manager = new TestPluginManager($this->namespaces, $definitions, $module_handler, 'test_alter_hook'); + + $this->assertEmpty($plugin_manager->getDefinition('cherry'), 'Plugin information of a disabled module is not available'); + } + /** * Tests the plugin manager with no cache and altering. */ @@ -188,3 +213,7 @@ public function testCacheClearWithTags() { } } + +if (!defined('DRUPAL_ROOT')) { + define('DRUPAL_ROOT', dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))))); +} diff --git a/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php b/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php index e88008ee2be0f7e017e3d535236e3945e68d8bc2..a7ea79df5f7104e59264000979e8aff7710d7d45 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php +++ b/core/tests/Drupal/Tests/Core/Plugin/TestPluginManager.php @@ -41,8 +41,10 @@ public function __construct(\Traversable $namespaces, array $definitions, Module $this->discovery->setDefinition($key, $definition); } - if ($module_handler && $alter_hook) { - $this->alterInfo($module_handler, $alter_hook); + $this->moduleHandler = $module_handler; + + if ($alter_hook) { + $this->alterInfo($alter_hook); } }