class StaticDiscovery

A discovery mechanism that allows plugin definitions to be manually registered rather than actively discovered.

Hierarchy

Expanded class hierarchy of StaticDiscovery

5 files declare their use of StaticDiscovery
CacheDecoratorTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorTest.php
Contains \Drupal\system\Tests\Plugin\CacheDecoratorTest.
DefaultsTestPluginManager.php in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/DefaultsTestPluginManager.php
Contains Drupal\plugin_test\Plugin\DefaultsTestPluginManager.
MockBlockManager.php in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/MockBlockManager.php
Definition of Drupal\plugin_test\Plugin\MockBlockManager.
StaticDiscoveryTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/StaticDiscoveryTest.php
Definition of Drupal\system\Tests\Plugin\Discovery\StaticDiscoveryTest.
TestPluginManager.php in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/TestPluginManager.php
Definition of Drupal\plugin_test\Plugin\TestPluginManager.

File

drupal/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php, line 14
Definition of Drupal\Component\Plugin\Discovery\StaticDiscovery.

Namespace

Drupal\Component\Plugin\Discovery
View source
class StaticDiscovery implements DiscoveryInterface {

  /**
   * The array of plugin definitions, keyed by plugin id.
   *
   * @var array
   */
  protected $definitions = array();

  /**
   * Implements Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinition().
   */
  public function getDefinition($base_plugin_id) {
    return isset($this->definitions[$base_plugin_id]) ? $this->definitions[$base_plugin_id] : NULL;
  }

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

  /**
   * Sets a plugin definition.
   */
  public function setDefinition($plugin, array $definition) {
    $this->definitions[$plugin] = $definition;
  }

  /**
   * Deletes a plugin definition.
   */
  public function deleteDefinition($plugin) {
    unset($this->definitions[$plugin]);
  }

}

Members