You are here

class MockManager in Plugin 8.2

Provides a plugin manager for testing plugin-related functionality.

Configuration schemas for this manager's plugins are named "plugin_test_helper.plugin_configuration.plugin_test_helper_mock.[plugin_id]", where "[plugin_id]" is the ID of the plugin the schema is for.

Hierarchy

Expanded class hierarchy of MockManager

1 file declares its use of MockManager
PluginCollectionItemBaseTest.php in tests/src/Kernel/Plugin/Field/FieldType/PluginCollectionItemBaseTest.php
1 string reference to 'MockManager'
plugin_test_helper.services.yml in tests/modules/plugin_test_helper/plugin_test_helper.services.yml
tests/modules/plugin_test_helper/plugin_test_helper.services.yml
1 service uses MockManager
plugin.manager.plugin_test_helper.mock in tests/modules/plugin_test_helper/plugin_test_helper.services.yml
Drupal\plugin_test_helper\Plugin\PluginTestHelper\MockManager

File

tests/modules/plugin_test_helper/src/Plugin/PluginTestHelper/MockManager.php, line 18

Namespace

Drupal\plugin_test_helper\Plugin\PluginTestHelper
View source
class MockManager extends PluginManagerBase implements TypedDiscoveryInterface {

  /**
   * Constructs a new instance.
   */
  public function __construct() {
    $this->discovery = new StaticDiscovery();
    $plugin_id = 'plugin_test_helper_plugin';
    $this->discovery
      ->setDefinition($plugin_id, new ArrayPluginDefinitionDecorator([
      'id' => $plugin_id,
      'label' => t('Plugin'),
      'class' => MockPlugin::class,
    ]));
    $configurable_plugin_id = 'plugin_test_helper_configurable_plugin';
    $this->discovery
      ->setDefinition($configurable_plugin_id, new ArrayPluginDefinitionDecorator([
      'id' => $configurable_plugin_id,
      'label' => t('Configurable plugin'),
      'class' => MockConfigurablePlugin::class,
    ]));
    $this->factory = new DefaultFactory($this->discovery);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
DiscoveryTrait::hasDefinition public function
MockManager::__construct public function Constructs a new instance.
PluginManagerBase::$discovery protected property The object that discovers plugins managed by this manager.
PluginManagerBase::$factory protected property The object that instantiates plugins managed by this manager.
PluginManagerBase::$mapper protected property The object that returns the preconfigured plugin instance appropriate for a particular runtime condition.
PluginManagerBase::createInstance public function Creates a pre-configured instance of a plugin. Overrides FactoryInterface::createInstance 12
PluginManagerBase::getDefinition public function Gets a specific plugin definition. Overrides DiscoveryTrait::getDefinition
PluginManagerBase::getDefinitions public function Gets the definition of all plugins for this type. Overrides DiscoveryTrait::getDefinitions
PluginManagerBase::getDiscovery protected function Gets the plugin discovery. 1
PluginManagerBase::getFactory protected function Gets the plugin factory. 1
PluginManagerBase::getInstance public function Gets a preconfigured instance of a plugin. Overrides MapperInterface::getInstance 7
PluginManagerBase::handlePluginNotFound protected function Allows plugin managers to specify custom behavior if a plugin is not found. 1