abstract class PluginManagerBase

Base class for plugin managers.

Hierarchy

Expanded class hierarchy of PluginManagerBase

25 files declare their use of PluginManagerBase
ActionManager.php in drupal/core/lib/Drupal/Core/Action/ActionManager.php
Contains \Drupal\Core\Action\ActionManager.
AggregatorPluginManager.php in drupal/core/modules/aggregator/lib/Drupal/aggregator/Plugin/AggregatorPluginManager.php
Contains \Drupal\aggregator\Plugin\AggregatorPluginManager.
ArchiverManager.php in drupal/core/lib/Drupal/Core/Archiver/ArchiverManager.php
BlockManager.php in drupal/core/modules/block/lib/Drupal/block/Plugin/Type/BlockManager.php
CKEditorPluginManager.php in drupal/core/modules/ckeditor/lib/Drupal/ckeditor/CKEditorPluginManager.php
Contains \Drupal\ckeditor\CKEditorPluginManager.

... See full list

File

drupal/core/lib/Drupal/Component/Plugin/PluginManagerBase.php, line 16
Definition of Drupal\Component\Plugin\PluginManagerBase

Namespace

Drupal\Component\Plugin
View source
abstract class PluginManagerBase implements PluginManagerInterface, CachedDiscoveryInterface {

  /**
   * The object that discovers plugins managed by this manager.
   *
   * @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
   */
  protected $discovery;

  /**
   * The object that instantiates plugins managed by this manager.
   *
   * @var \Drupal\Component\Plugin\Factory\FactoryInterface
   */
  protected $factory;

  /**
   * The object that returns the preconfigured plugin instance appropriate for a particular runtime condition.
   *
   * @var \Drupal\Component\Plugin\Mapper\MapperInterface
   */
  protected $mapper;

  /**
   * A set of defaults to be referenced by $this->processDefinition() if
   * additional processing of plugins is necessary or helpful for development
   * purposes.
   *
   * @var array
   */
  protected $defaults = array();

  /**
   * {@inheritdoc}
   */
  public function getDefinition($plugin_id) {
    return $this->discovery
      ->getDefinition($plugin_id);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefinitions() {
    return $this->discovery
      ->getDefinitions();
  }

  /**
   * {@inheritdoc}
   */
  public function clearCachedDefinitions() {
    if ($this->discovery instanceof CachedDiscoveryInterface) {
      $this->discovery
        ->clearCachedDefinitions();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function createInstance($plugin_id, array $configuration = array()) {
    return $this->factory
      ->createInstance($plugin_id, $configuration);
  }

  /**
   * {@inheritdoc}
   */
  public function getInstance(array $options) {
    return $this->mapper
      ->getInstance($options);
  }

  /**
   * Performs extra processing on plugin definitions.
   *
   * By default we add defaults for the type to the definition. If a type has
   * additional processing logic they can do that by replacing or extending the
   * method.
   */
  public function processDefinition(&$definition, $plugin_id) {
    $definition = NestedArray::mergeDeep($this->defaults, $definition);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PluginManagerBase::$defaults protected property A set of defaults to be referenced by $this->processDefinition() if additional processing of plugins is necessary or helpful for development purposes. 3
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::clearCachedDefinitions public function Clears static and persistent plugin definition caches. Overrides CachedDiscoveryInterface::clearCachedDefinitions
PluginManagerBase::createInstance public function Returns a preconfigured instance of a plugin. Overrides FactoryInterface::createInstance 6
PluginManagerBase::getDefinition public function Gets a specific plugin definition. Overrides DiscoveryInterface::getDefinition
PluginManagerBase::getDefinitions public function Gets the definition of all plugins for this type. Overrides DiscoveryInterface::getDefinitions
PluginManagerBase::getInstance public function Returns a preconfigured instance of a plugin. Overrides MapperInterface::getInstance 6
PluginManagerBase::processDefinition public function Performs extra processing on plugin definitions. 2