diff --git a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php index 1fe5160..ddebeaf 100644 --- a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php +++ b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php @@ -8,6 +8,7 @@ namespace Drupal\Component\Plugin; use Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface; +use Drupal\Component\Plugin\Exception\PluginException; /** * Base class for plugin managers. @@ -29,13 +30,6 @@ protected $factory; /** - * The object that returns the preconfigured plugin instance appropriate for a particular runtime condition. - * - * @var \Drupal\Component\Plugin\Mapper\MapperInterface - */ - protected $mapper; - - /** * {@inheritdoc} */ public function getDefinition($plugin_id) { @@ -69,7 +63,7 @@ public function createInstance($plugin_id, array $configuration = array()) { * {@inheritdoc} */ public function getInstance(array $options) { - return $this->mapper->getInstance($options); + throw new PluginException('No implementation of MapperInterface::getInstance() was provided'); } } diff --git a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php index 4862ac7..e405f59 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/DefaultPluginManagerTest.php @@ -214,6 +214,17 @@ public function testCacheClearWithTags() { $plugin_manager->clearCachedDefinitions(); } + /** + * Tests the getInstance() method. + * + * @expectedException \Drupal\Component\Plugin\Exception\PluginException + * @expectedExceptionMessage No implementation of MapperInterface::getInstance() was provided + */ + public function testGetInstance() { + $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions); + $this->assertNull($plugin_manager->getInstance(array())); + } + } if (!defined('DRUPAL_ROOT')) {