DeriverInterface.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Drupal\Component\Plugin\Derivative;
  3. /**
  4. * Provides additional plugin definitions based on an existing definition.
  5. *
  6. * @ingroup plugin_api
  7. */
  8. interface DeriverInterface {
  9. /**
  10. * Gets the definition of a derivative plugin.
  11. *
  12. * @param string $derivative_id
  13. * The derivative id. The id must uniquely identify the derivative within a
  14. * given base plugin, but derivative ids can be reused across base plugins.
  15. * @param array|\Drupal\Component\Plugin\Definition\PluginDefinitionInterface $base_plugin_definition
  16. * The definition of the base plugin from which the derivative plugin
  17. * is derived. It is maybe an entire object or just some array, depending
  18. * on the discovery mechanism.
  19. *
  20. * @return array
  21. * The full definition array of the derivative plugin, typically a merge of
  22. * $base_plugin_definition with extra derivative-specific information. NULL
  23. * if the derivative doesn't exist.
  24. */
  25. public function getDerivativeDefinition($derivative_id, $base_plugin_definition);
  26. /**
  27. * Gets the definition of all derivatives of a base plugin.
  28. *
  29. * @param array $base_plugin_definition
  30. * The definition array of the base plugin.
  31. *
  32. * @return array
  33. * An array of full derivative definitions keyed on derivative id.
  34. *
  35. * @see getDerivativeDefinition()
  36. */
  37. public function getDerivativeDefinitions($base_plugin_definition);
  38. }