ContextInterface.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Drupal\Component\Plugin\Context;
  3. /**
  4. * Provides data and definitions for plugins during runtime and administration.
  5. *
  6. * Plugin contexts are satisfied by ContextInterface implementing objects.
  7. * These objects always contain a definition of what data they will provide
  8. * during runtime. During run time, ContextInterface implementing objects must
  9. * also provide the corresponding data value.
  10. *
  11. * @see \Drupal\Component\Plugin\Context\ContextDefinitionInterface
  12. */
  13. interface ContextInterface {
  14. /**
  15. * Gets the context value.
  16. *
  17. * @return mixed
  18. * The currently set context value, or NULL if it is not set.
  19. */
  20. public function getContextValue();
  21. /**
  22. * Returns whether the context has a value.
  23. *
  24. * @return bool
  25. * TRUE if the context has a value, FALSE otherwise.
  26. */
  27. public function hasContextValue();
  28. /**
  29. * Gets the provided definition that the context must conform to.
  30. *
  31. * @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
  32. * The defining characteristic representation of the context.
  33. */
  34. public function getContextDefinition();
  35. /**
  36. * Gets a list of validation constraints.
  37. *
  38. * @return array
  39. * Array of constraints, each being an instance of
  40. * \Symfony\Component\Validator\Constraint.
  41. */
  42. public function getConstraints();
  43. /**
  44. * Validates the set context value.
  45. *
  46. * @return \Symfony\Component\Validator\ConstraintViolationListInterface
  47. * A list of constraint violations. If the list is empty, validation
  48. * succeeded.
  49. */
  50. public function validate();
  51. }