FilteredPluginManagerInterface.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Drupal\Core\Plugin;
  3. use Drupal\Component\Plugin\PluginManagerInterface;
  4. /**
  5. * Provides an interface for plugin managers that allow filtering definitions.
  6. */
  7. interface FilteredPluginManagerInterface extends PluginManagerInterface {
  8. /**
  9. * Gets the plugin definitions for a given type and consumer and filters them.
  10. *
  11. * This allows modules and themes to alter plugin definitions at runtime,
  12. * which is useful for tasks like hiding specific plugins from a particular
  13. * user interface.
  14. *
  15. * @param string $consumer
  16. * A string identifying the consumer of these plugin definitions.
  17. * @param \Drupal\Component\Plugin\Context\ContextInterface[]|null $contexts
  18. * (optional) Either an array of contexts to use for filtering, or NULL to
  19. * not filter by contexts.
  20. * @param mixed[] $extra
  21. * (optional) An associative array containing additional information
  22. * provided by the code requesting the filtered definitions.
  23. *
  24. * @return \Drupal\Component\Plugin\Definition\PluginDefinitionInterface[]|array[]
  25. * An array of plugin definitions that are filtered.
  26. *
  27. * @see hook_plugin_filter_TYPE_alter()
  28. * @see hook_plugin_filter_TYPE__CONSUMER_alter()
  29. */
  30. public function getFilteredDefinitions($consumer, $contexts = NULL, array $extra = []);
  31. }