StaticDiscovery.php

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

Namespace

Drupal\Component\Plugin\Discovery

File

core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php

View source
<?php

namespace Drupal\Component\Plugin\Discovery;


/**
 * A discovery mechanism that allows plugin definitions to be manually
 * registered rather than actively discovered.
 */
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]);
    }

}

Classes

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

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