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 b39b44d..0cbcba4 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php @@ -35,6 +35,13 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa protected $typedConfigManager; /** + * The theme handler. + * + * @var \Drupal\Core\Extension\ThemeHandlerInterface + */ + protected $themeHandler; + + /** * {@inheritdoc} */ protected $defaults = array( @@ -78,6 +85,8 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage // Let others alter definitions with hook_config_translation_info_alter(). $this->moduleHandler = $module_handler; + $this->themeHandler = $theme_handler; + $this->alterInfo('config_translation_info'); $this->setCacheBackend($cache_backend, $language_manager, 'config_translation_info_plugins'); } @@ -108,6 +117,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} + */ public function hasTranslatable($name) { return $this->findTranslatable($this->typedConfigManager->get($name)); } 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 068fe65..50d5736 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php @@ -36,7 +36,8 @@ public function setUp() { // - MockBlockManager is used for testing more advanced functionality such // as derivatives and ReflectionFactory. $this->testPluginManager = new TestPluginManager(); - $this->mockBlockManager = new MockBlockManager();$module_handler = new ModuleHandler(); + $this->mockBlockManager = new MockBlockManager(); + $module_handler = new ModuleHandler(); $this->defaultsTestPluginManager = new DefaultsTestPluginManager($module_handler); // The expected plugin definitions within each manager. Several tests assert