3 namespace Drupal\block;
5 use Drupal\Core\Block\BlockPluginInterface;
6 use Drupal\Core\Config\Entity\ConfigEntityInterface;
9 * Provides an interface defining a block entity.
11 interface BlockInterface extends ConfigEntityInterface {
14 * Indicates the block label (title) should be displayed to end users.
16 * @deprecated in Drupal 8.3.x, will be removed before Drupal 9.0.0.
17 * Use \Drupal\Core\Block\BlockPluginInterface::BLOCK_LABEL_VISIBLE.
19 * @see https://www.drupal.org/node/2829775
21 const BLOCK_LABEL_VISIBLE = BlockPluginInterface::BLOCK_LABEL_VISIBLE;
24 * Denotes that a block is not enabled in any region and should not be shown.
26 * @deprecated Scheduled for removal in Drupal 9.0.0.
28 const BLOCK_REGION_NONE = -1;
31 * Returns the plugin instance.
33 * @return \Drupal\Core\Block\BlockPluginInterface
34 * The plugin instance for this block.
36 public function getPlugin();
39 * Returns the plugin ID.
42 * The plugin ID for this block.
44 public function getPluginId();
47 * Returns the region this block is placed in.
50 * The region this block is placed in.
52 public function getRegion();
55 * Returns the theme ID.
58 * The theme ID for this block instance.
60 public function getTheme();
63 * Returns an array of visibility condition configurations.
66 * An array of visibility condition configuration keyed by the condition ID.
68 public function getVisibility();
71 * Gets conditions for this block.
73 * @return \Drupal\Core\Condition\ConditionInterface[]|\Drupal\Core\Condition\ConditionPluginCollection
74 * An array or collection of configured condition plugins.
76 public function getVisibilityConditions();
79 * Gets a visibility condition plugin instance.
81 * @param string $instance_id
82 * The condition plugin instance ID.
84 * @return \Drupal\Core\Condition\ConditionInterface
87 public function getVisibilityCondition($instance_id);
90 * Sets the visibility condition configuration.
92 * @param string $instance_id
93 * The condition instance ID.
94 * @param array $configuration
95 * The condition configuration.
99 public function setVisibilityConfig($instance_id, array $configuration);
102 * Returns the weight of this block (used for sorting).
107 public function getWeight();
110 * Sets the region this block is placed in.
112 * @param string $region
113 * The region to place this block in.
117 public function setRegion($region);
120 * Sets the block weight.
123 * The desired weight.
127 public function setWeight($weight);
130 * Creates a duplicate of the block entity.
132 * @param string $new_id
133 * (optional) The new ID on the duplicate block.
134 * @param string $new_theme
135 * (optional) The theme on the duplicate block.
138 * A clone of $this with all identifiers unset, so saving it inserts a new
139 * entity into the storage system.
141 public function createDuplicateBlock($new_id = NULL, $new_theme = NULL);