diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index eb5eeee..53a9b5b 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -259,7 +259,11 @@ protected function findDefinitions() { * * @throws \Drupal\Component\Plugin\Exception\PluginException */ - protected function enforcePluginInterface($plugin_id, $plugin_definition) { + protected function enforcePluginInterface($plugin_id, array $plugin_definition) { + // Make it possible to not specify an interface. + if (!isset($this->interface)) { + return; + } // If there are multiple valid interfaces, check for at least one. if (is_array($this->interface) && array_intersect(class_implements($plugin_definition['class']), $this->interface)) { return; diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 7889be1..c9afe86 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -395,11 +395,4 @@ public function clearCachedDefinitions() { $this->prototypes = array(); } - /** - * {@inheritdoc} - */ - protected function enforcePluginInterface($plugin_id, $plugin_definition) { - // Do not enforce an interface for typed data plugins. - } - } diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index 70adb95..a2b46d3 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -138,12 +138,4 @@ public function getDefinitionsByType($type) { } return $definitions; } - - /** - * {@inheritdoc} - */ - protected function enforcePluginInterface($plugin_id, $plugin_definition) { - // Do not enforce an interface for constraint plugins. - } - } diff --git a/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php index 619e125..1e5d4b6 100644 --- a/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php +++ b/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php @@ -7,8 +7,6 @@ namespace Drupal\aggregator\Plugin; -use Drupal\Component\Plugin\Exception\PluginException; -use Drupal\Component\Utility\String; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateLoadInterface.php b/core/modules/migrate_drupal/src/Plugin/MigrateLoadInterface.php index f5545e8..ce3ed83 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateLoadInterface.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateLoadInterface.php @@ -2,7 +2,7 @@ /** * @file - * Contains Drupal\migrate\Plugin\MigrateLoadInterface + * Contains Drupal\migrate_drupal\Plugin\MigrateLoadInterface */ namespace Drupal\migrate_drupal\Plugin; diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index c202cbc..4b3652c 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -254,6 +254,34 @@ public function testGetDefinitionsWithInvalidInterfaces() { $plugin_manager->getDefinitions(); } + /** + * Tests plugins without a required interface. + * + * @covers ::getDefinitions + * @covers ::enforcePluginInterface + */ + public function testGetDefinitionsWithoutRequiredInterface() { + $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); + + $module_handler->expects($this->any()) + ->method('moduleExists') + ->with('plugin_test') + ->willReturn(FALSE); + + $this->expectedDefinitions['kale'] = array( + 'id' => 'kale', + 'label' => 'Kale', + 'color' => 'green', + 'class' => 'Drupal\plugin_test\Plugin\plugin_test\fruit\Kale', + 'provider' => 'plugin_test', + ); + $this->expectedDefinitions['apple']['provider'] = 'plugin_test'; + $this->expectedDefinitions['banana']['provider'] = 'plugin_test'; + + $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler, NULL); + $plugin_manager->getDefinitions(); + } + } if (!defined('DRUPAL_ROOT')) {