abstract class PluginManagerBase

Base class for plugin managers.

Hierarchy

Expanded class hierarchy of PluginManagerBase

13 files declare their use of PluginManagerBase
DefaultsTestPluginManager.php in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/DefaultsTestPluginManager.php
Contains Drupal\plugin_test\Plugin\DefaultsTestPluginManager.
EntityManager.php in drupal/core/lib/Drupal/Core/Entity/EntityManager.php
Contains \Drupal\Core\Entity\EntityManager.
FetcherManager.php in drupal/core/modules/aggregator/lib/Drupal/aggregator/Plugin/FetcherManager.php
Definition of Drupal\aggregator\Plugin\FetcherManager.
FormatterPluginManager.php in drupal/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php
Definition of Drupal\field\Plugin\Type\Formatter\FormatterPluginManager..
JoinManager.php in drupal/core/modules/views/lib/Drupal/views/Plugin/Type/JoinManager.php
Definition of Drupal\views\Plugin\Type\JoinManager.

... 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();

  /**
   * Implements Drupal\Component\Plugin\PluginManagerInterface::getDefinition().
   */
  public function getDefinition($plugin_id) {
    return $this->discovery
      ->getDefinition($plugin_id);
  }

  /**
   * Implements Drupal\Component\Plugin\PluginManagerInterface::getDefinitions().
   */
  public function getDefinitions() {
    return $this->discovery
      ->getDefinitions();
  }

  /**
   * Implements \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface::clearCachedDefinitions().
   */
  public function clearCachedDefinitions() {
    if ($this->discovery instanceof CachedDiscoveryInterface) {
      $this->discovery
        ->clearCachedDefinitions();
    }
  }

  /**
   * Implements Drupal\Component\Plugin\PluginManagerInterface::createInstance().
   */
  public function createInstance($plugin_id, array $configuration = array()) {
    return $this->factory
      ->createInstance($plugin_id, $configuration);
  }

  /**
   * Implements Drupal\Component\Plugin\PluginManagerInterface::getInstance().
   */
  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. 4
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 Implements \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface::clearCachedDefinitions(). Overrides CachedDiscoveryInterface::clearCachedDefinitions
PluginManagerBase::createInstance public function Implements Drupal\Component\Plugin\PluginManagerInterface::createInstance(). Overrides FactoryInterface::createInstance 1
PluginManagerBase::getDefinition public function Implements Drupal\Component\Plugin\PluginManagerInterface::getDefinition(). Overrides DiscoveryInterface::getDefinition 1
PluginManagerBase::getDefinitions public function Implements Drupal\Component\Plugin\PluginManagerInterface::getDefinitions(). Overrides DiscoveryInterface::getDefinitions 1
PluginManagerBase::getInstance public function Implements Drupal\Component\Plugin\PluginManagerInterface::getInstance(). Overrides MapperInterface::getInstance 3
PluginManagerBase::processDefinition public function Performs extra processing on plugin definitions. 2