StaticDiscovery.php 725 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Drupal\Component\Plugin\Discovery;
  3. /**
  4. * A discovery mechanism that allows plugin definitions to be manually
  5. * registered rather than actively discovered.
  6. */
  7. class StaticDiscovery implements DiscoveryInterface {
  8. use DiscoveryCachedTrait;
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function getDefinitions() {
  13. if (!$this->definitions) {
  14. $this->definitions = [];
  15. }
  16. return $this->definitions;
  17. }
  18. /**
  19. * Sets a plugin definition.
  20. */
  21. public function setDefinition($plugin, $definition) {
  22. $this->definitions[$plugin] = $definition;
  23. }
  24. /**
  25. * Deletes a plugin definition.
  26. */
  27. public function deleteDefinition($plugin) {
  28. unset($this->definitions[$plugin]);
  29. }
  30. }