diff -u b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php --- b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -278,7 +278,7 @@ $this->processDefinition($definition, $plugin_id); } $this->alterDefinitions($definitions); - return ProviderFilterDecorator::filterDefinitions($definitions, $this->moduleHandler); + return ProviderFilterDecorator::filterDefinitions($definitions, [$this, 'providerExists']); } /** @@ -298,10 +298,8 @@ * * @return bool * TRUE if provider exists, FALSE otherwise. - * - * @deprecated Will be removed in Drupal 9.0 as it is not needed now. */ - protected function providerExists($provider) { + public function providerExists($provider) { return $this->moduleHandler->moduleExists($provider); } diff -u b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php --- b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/ProviderFilterDecorator.php @@ -21,9 +21,9 @@ protected $decorated; /** - * @var \Drupal\Core\Extension\ModuleHandlerInterface + * @var callable */ - protected $moduleHandler; + protected $providerExists; /** * Constructs a InheritProviderDecorator object. @@ -33,9 +33,9 @@ * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ - public function __construct(DiscoveryInterface $decorated, ModuleHandlerInterface $module_handler) { + public function __construct(DiscoveryInterface $decorated, callable $provider_exists) { $this->decorated = $decorated; - $this->moduleHandler = $module_handler; + $this->providerExists = $provider_exists; } /** @@ -44,14 +44,15 @@ * @param mixed[] $definitions * An array of plugin definitions (empty array if no definitions were * found). Keys are plugin IDs. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. + * @param callable $provider_exists + * A callable, gets passed a provider name, should return TRUE if the + * provider exists and FALSE if not. * - * @return $definitions + * @return array|\mixed[] $definitions * An array of plugin definitions. If a definition is an array and has a * provider key that provider is guaranteed to exist. */ - public static function filterDefinitions(array $definitions, ModuleHandlerInterface $module_handler) { + public static function filterDefinitions(array $definitions, callable $provider_exists) { foreach ($definitions as $plugin_id => $plugin_definition) { // If the plugin definition is an object, attempt to convert it to an // array, if that is not possible, skip further processing. @@ -59,7 +60,7 @@ continue; } foreach ((array) $plugin_definition['provider'] as $provider) { - if (!in_array($provider, ['core', 'component']) && !$module_handler->moduleExists($provider)) { + if (!in_array($provider, ['core', 'component']) && !$provider_exists($provider)) { unset($definitions[$plugin_id]); } } @@ -71,7 +72,7 @@ * {@inheritdoc} */ public function getDefinitions() { - return static::filterDefinitions($this->decorated->getDefinitions(), $this->moduleHandler); + return static::filterDefinitions($this->decorated->getDefinitions(), $this->providerExists); } /** diff -u b/core/modules/migrate/src/Plugin/MigrationPluginManager.php b/core/modules/migrate/src/Plugin/MigrationPluginManager.php --- b/core/modules/migrate/src/Plugin/MigrationPluginManager.php +++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php @@ -10,7 +10,6 @@ use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\ProviderFilterDecorator; -use Drupal\Core\Plugin\Discovery\ProviderAwareContainerDerivativeDiscoveryDecorator; use Drupal\Core\Plugin\Discovery\YamlDirectoryDiscovery; use Drupal\Core\Plugin\Factory\ContainerFactory; use Drupal\migrate\MigrateBuildDependencyInterface; @@ -71,7 +70,7 @@ $yaml_discovery = new YamlDirectoryDiscovery($directories, 'migrate'); $inherited_discovery = new InheritProviderDecorator($yaml_discovery); - $filtered_discovery = new ProviderFilterDecorator($inherited_discovery, $this->moduleHandler); + $filtered_discovery = new ProviderFilterDecorator($inherited_discovery, [$this->moduleHandler, 'moduleExists']); $this->discovery = new ContainerDerivativeDiscoveryDecorator($filtered_discovery); } return $this->discovery; only in patch2: unchanged: --- a/core/modules/breakpoint/src/BreakpointManager.php +++ b/core/modules/breakpoint/src/BreakpointManager.php @@ -140,7 +140,7 @@ public function processDefinition(&$definition, $plugin_id) { /** * {@inheritdoc} */ - protected function providerExists($provider) { + public function providerExists($provider) { return $this->moduleHandler->moduleExists($provider) || $this->themeHandler->themeExists($provider); } only in patch2: unchanged: --- a/core/modules/migrate/tests/src/Kernel/MigrationTest.php +++ b/core/modules/migrate/tests/src/Kernel/MigrationTest.php @@ -34,8 +34,8 @@ public function testSetInvalidation() { $this->assertEqual('entity:entity_view_mode', $migration->getDestinationPlugin()->getPluginId()); // Test the source plugin is invalidated. - $migration->set('source', ['plugin' => 'd6_field']); - $this->assertEqual('d6_field', $migration->getSourcePlugin()->getPluginId()); + $migration->set('source', ['plugin' => 'embedded_data', 'data_rows' => [], 'ids' => []]); + $this->assertEqual('embedded_data', $migration->getSourcePlugin()->getPluginId()); // Test the destination plugin is invalidated. $migration->set('destination', ['plugin' => 'null']);