DiscoveryInterface.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Drupal\Component\Plugin\Discovery;
  3. /**
  4. * An interface defining the minimum requirements of building a plugin
  5. * discovery component.
  6. *
  7. * @ingroup plugin_api
  8. */
  9. interface DiscoveryInterface {
  10. /**
  11. * Gets a specific plugin definition.
  12. *
  13. * @param string $plugin_id
  14. * A plugin id.
  15. * @param bool $exception_on_invalid
  16. * (optional) If TRUE, an invalid plugin ID will throw an exception.
  17. *
  18. * @return mixed
  19. * A plugin definition, or NULL if the plugin ID is invalid and
  20. * $exception_on_invalid is FALSE.
  21. *
  22. * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
  23. * Thrown if $plugin_id is invalid and $exception_on_invalid is TRUE.
  24. */
  25. public function getDefinition($plugin_id, $exception_on_invalid = TRUE);
  26. /**
  27. * Gets the definition of all plugins for this type.
  28. *
  29. * @return mixed[]
  30. * An array of plugin definitions (empty array if no definitions were
  31. * found). Keys are plugin IDs.
  32. *
  33. * @see \Drupal\Core\Plugin\FilteredPluginManagerInterface::getFilteredDefinitions()
  34. */
  35. public function getDefinitions();
  36. /**
  37. * Indicates if a specific plugin definition exists.
  38. *
  39. * @param string $plugin_id
  40. * A plugin ID.
  41. *
  42. * @return bool
  43. * TRUE if the definition exists, FALSE otherwise.
  44. */
  45. public function hasDefinition($plugin_id);
  46. }