class StaticDiscovery

Same name in other branches
  1. 9 core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php \Drupal\Component\Plugin\Discovery\StaticDiscovery
  2. 8.9.x core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php \Drupal\Component\Plugin\Discovery\StaticDiscovery
  3. 11.x core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php \Drupal\Component\Plugin\Discovery\StaticDiscovery

Allows plugin definitions to be manually registered.

Hierarchy

Expanded class hierarchy of StaticDiscovery

6 files declare their use of StaticDiscovery
DefaultsTestPluginManager.php in core/modules/system/tests/modules/plugin_test/src/Plugin/DefaultsTestPluginManager.php
MockBlockManager.php in core/modules/system/tests/modules/plugin_test/src/Plugin/MockBlockManager.php
StaticDiscoveryDecoratorTest.php in core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
StaticDiscoveryTest.php in core/tests/Drupal/KernelTests/Core/Plugin/Discovery/StaticDiscoveryTest.php
TestPluginManager.php in core/modules/system/tests/modules/plugin_test/src/Plugin/TestPluginManager.php

... See full list

File

core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php, line 8

Namespace

Drupal\Component\Plugin\Discovery
View source
class StaticDiscovery implements DiscoveryInterface {
    use DiscoveryCachedTrait;
    
    /**
     * {@inheritdoc}
     */
    public function getDefinitions() {
        if (!$this->definitions) {
            $this->definitions = [];
        }
        return $this->definitions;
    }
    
    /**
     * Sets a plugin definition.
     */
    public function setDefinition($plugin, $definition) {
        $this->definitions[$plugin] = $definition;
    }
    
    /**
     * Deletes a plugin definition.
     */
    public function deleteDefinition($plugin) {
        unset($this->definitions[$plugin]);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DiscoveryCachedTrait::$definitions protected property Cached definitions array. 1
DiscoveryCachedTrait::getDefinition public function Overrides DiscoveryTrait::getDefinition 3
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
DiscoveryTrait::hasDefinition public function
StaticDiscovery::deleteDefinition public function Deletes a plugin definition.
StaticDiscovery::getDefinitions public function Gets the definition of all plugins for this type. Overrides DiscoveryTrait::getDefinitions 2
StaticDiscovery::setDefinition public function Sets a plugin definition.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.