VariantInterface.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace Drupal\Core\Display;
  3. use Drupal\Component\Plugin\ConfigurablePluginInterface;
  4. use Drupal\Component\Plugin\PluginInspectionInterface;
  5. use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
  6. use Drupal\Core\Plugin\PluginFormInterface;
  7. use Drupal\Core\Session\AccountInterface;
  8. /**
  9. * Provides an interface for DisplayVariant plugins.
  10. *
  11. * @see \Drupal\Core\Display\Annotation\DisplayVariant
  12. * @see \Drupal\Core\Display\VariantBase
  13. * @see \Drupal\Core\Display\VariantManager
  14. * @see plugin_api
  15. */
  16. interface VariantInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface, RefinableCacheableDependencyInterface {
  17. /**
  18. * Returns the user-facing display variant label.
  19. *
  20. * @return string
  21. * The display variant label.
  22. */
  23. public function label();
  24. /**
  25. * Returns the admin-facing display variant label.
  26. *
  27. * This is for the type of display variant, not the configured variant itself.
  28. *
  29. * @return string
  30. * The display variant administrative label.
  31. */
  32. public function adminLabel();
  33. /**
  34. * Returns the unique ID for the display variant.
  35. *
  36. * @return string
  37. * The display variant ID.
  38. */
  39. public function id();
  40. /**
  41. * Returns the weight of the display variant.
  42. *
  43. * @return int
  44. * The display variant weight.
  45. */
  46. public function getWeight();
  47. /**
  48. * Sets the weight of the display variant.
  49. *
  50. * @param int $weight
  51. * The weight to set.
  52. */
  53. public function setWeight($weight);
  54. /**
  55. * Determines if this display variant is accessible.
  56. *
  57. * @param \Drupal\Core\Session\AccountInterface $account
  58. * (optional) The user for which to check access, or NULL to check access
  59. * for the current user. Defaults to NULL.
  60. *
  61. * @return bool
  62. * TRUE if this display variant is accessible, FALSE otherwise.
  63. */
  64. public function access(AccountInterface $account = NULL);
  65. /**
  66. * Builds and returns the renderable array for the display variant.
  67. *
  68. * The variant can contain cacheability metadata for the configuration that
  69. * was passed in setConfiguration(). In the build() method, this should be
  70. * added to the render array that is returned.
  71. *
  72. * @return array
  73. * A render array for the display variant.
  74. */
  75. public function build();
  76. }