EntityDisplayInterface.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace Drupal\Core\Entity\Display;
  3. use Drupal\Core\Config\Entity\ConfigEntityInterface;
  4. use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
  5. /**
  6. * Provides a common interface for entity displays.
  7. */
  8. interface EntityDisplayInterface extends ConfigEntityInterface, EntityWithPluginCollectionInterface {
  9. /**
  10. * Creates a duplicate of the entity display object on a different view mode.
  11. *
  12. * The new object necessarily has the same $targetEntityType and $bundle
  13. * properties than the original one.
  14. *
  15. * @param string $view_mode
  16. * The view mode for the new object.
  17. *
  18. * @return static
  19. * A duplicate of this object with the given view mode.
  20. */
  21. public function createCopy($view_mode);
  22. /**
  23. * Gets the display options for all components.
  24. *
  25. * @return array
  26. * The array of display options, keyed by component name.
  27. */
  28. public function getComponents();
  29. /**
  30. * Gets the display options set for a component.
  31. *
  32. * @param string $name
  33. * The name of the component.
  34. *
  35. * @return array|null
  36. * The display options for the component, or NULL if the component is not
  37. * displayed.
  38. */
  39. public function getComponent($name);
  40. /**
  41. * Sets the display options for a component.
  42. *
  43. * @param string $name
  44. * The name of the component.
  45. * @param array $options
  46. * The display options.
  47. *
  48. * @return $this
  49. */
  50. public function setComponent($name, array $options = []);
  51. /**
  52. * Sets a component to be hidden.
  53. *
  54. * @param string $name
  55. * The name of the component.
  56. *
  57. * @return $this
  58. */
  59. public function removeComponent($name);
  60. /**
  61. * Gets the highest weight of the components in the display.
  62. *
  63. * @return int|null
  64. * The highest weight of the components in the display, or NULL if the
  65. * display is empty.
  66. */
  67. public function getHighestWeight();
  68. /**
  69. * Gets the renderer plugin for a field (e.g. widget, formatter).
  70. *
  71. * @param string $field_name
  72. * The field name.
  73. *
  74. * @return \Drupal\Core\Field\PluginSettingsInterface|null
  75. * A widget or formatter plugin or NULL if the field does not exist.
  76. */
  77. public function getRenderer($field_name);
  78. /**
  79. * Gets the entity type for which this display is used.
  80. *
  81. * @return string
  82. * The entity type id.
  83. */
  84. public function getTargetEntityTypeId();
  85. /**
  86. * Gets the view or form mode to be displayed.
  87. *
  88. * @return string
  89. * The mode to be displayed.
  90. */
  91. public function getMode();
  92. /**
  93. * Gets the original view or form mode that was requested.
  94. *
  95. * @return string
  96. * The original mode that was requested.
  97. */
  98. public function getOriginalMode();
  99. /**
  100. * Gets the bundle to be displayed.
  101. *
  102. * @return string
  103. * The bundle to be displayed.
  104. */
  105. public function getTargetBundle();
  106. /**
  107. * Sets the bundle to be displayed.
  108. *
  109. * @param string $bundle
  110. * The bundle to be displayed.
  111. *
  112. * @return $this
  113. */
  114. public function setTargetBundle($bundle);
  115. }