BlockInterface.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace Drupal\block;
  3. use Drupal\Core\Block\BlockPluginInterface;
  4. use Drupal\Core\Config\Entity\ConfigEntityInterface;
  5. /**
  6. * Provides an interface defining a block entity.
  7. */
  8. interface BlockInterface extends ConfigEntityInterface {
  9. /**
  10. * Indicates the block label (title) should be displayed to end users.
  11. *
  12. * @deprecated in Drupal 8.3.x, will be removed before Drupal 9.0.0.
  13. * Use \Drupal\Core\Block\BlockPluginInterface::BLOCK_LABEL_VISIBLE.
  14. *
  15. * @see https://www.drupal.org/node/2829775
  16. */
  17. const BLOCK_LABEL_VISIBLE = BlockPluginInterface::BLOCK_LABEL_VISIBLE;
  18. /**
  19. * Denotes that a block is not enabled in any region and should not be shown.
  20. *
  21. * @deprecated Scheduled for removal in Drupal 9.0.0.
  22. */
  23. const BLOCK_REGION_NONE = -1;
  24. /**
  25. * Returns the plugin instance.
  26. *
  27. * @return \Drupal\Core\Block\BlockPluginInterface
  28. * The plugin instance for this block.
  29. */
  30. public function getPlugin();
  31. /**
  32. * Returns the plugin ID.
  33. *
  34. * @return string
  35. * The plugin ID for this block.
  36. */
  37. public function getPluginId();
  38. /**
  39. * Returns the region this block is placed in.
  40. *
  41. * @return string
  42. * The region this block is placed in.
  43. */
  44. public function getRegion();
  45. /**
  46. * Returns the theme ID.
  47. *
  48. * @return string
  49. * The theme ID for this block instance.
  50. */
  51. public function getTheme();
  52. /**
  53. * Returns an array of visibility condition configurations.
  54. *
  55. * @return array
  56. * An array of visibility condition configuration keyed by the condition ID.
  57. */
  58. public function getVisibility();
  59. /**
  60. * Gets conditions for this block.
  61. *
  62. * @return \Drupal\Core\Condition\ConditionInterface[]|\Drupal\Core\Condition\ConditionPluginCollection
  63. * An array or collection of configured condition plugins.
  64. */
  65. public function getVisibilityConditions();
  66. /**
  67. * Gets a visibility condition plugin instance.
  68. *
  69. * @param string $instance_id
  70. * The condition plugin instance ID.
  71. *
  72. * @return \Drupal\Core\Condition\ConditionInterface
  73. * A condition plugin.
  74. */
  75. public function getVisibilityCondition($instance_id);
  76. /**
  77. * Sets the visibility condition configuration.
  78. *
  79. * @param string $instance_id
  80. * The condition instance ID.
  81. * @param array $configuration
  82. * The condition configuration.
  83. *
  84. * @return $this
  85. */
  86. public function setVisibilityConfig($instance_id, array $configuration);
  87. /**
  88. * Returns the weight of this block (used for sorting).
  89. *
  90. * @return int
  91. * The block weight.
  92. */
  93. public function getWeight();
  94. /**
  95. * Sets the region this block is placed in.
  96. *
  97. * @param string $region
  98. * The region to place this block in.
  99. *
  100. * @return $this
  101. */
  102. public function setRegion($region);
  103. /**
  104. * Sets the block weight.
  105. *
  106. * @param int $weight
  107. * The desired weight.
  108. *
  109. * @return $this
  110. */
  111. public function setWeight($weight);
  112. /**
  113. * Creates a duplicate of the block entity.
  114. *
  115. * @param string $new_id
  116. * (optional) The new ID on the duplicate block.
  117. * @param string $new_theme
  118. * (optional) The theme on the duplicate block.
  119. *
  120. * @return static
  121. * A clone of $this with all identifiers unset, so saving it inserts a new
  122. * entity into the storage system.
  123. */
  124. public function createDuplicateBlock($new_id = NULL, $new_theme = NULL);
  125. }