summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/navigation/src/TopBarItemPluginInterface.php
blob: fc73a0dc767eb5ba236b2abf313c1d3a03f7f23d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

declare(strict_types=1);

namespace Drupal\navigation;

/**
 * Interface for top bar plugins.
 */
interface TopBarItemPluginInterface {

  /**
   * Returns the translated plugin label.
   *
   * @return string|\Stringable
   *   The translated plugin label.
   */
  public function label(): string|\Stringable;

  /**
   * Returns the plugin region.
   *
   * @return \Drupal\navigation\TopBarRegion
   *   The plugin region.
   */
  public function region(): TopBarRegion;

  /**
   * Builds and returns the renderable array for this top bar item plugin.
   *
   * If a top bar item should not be rendered because it has no content, then
   * this method must also ensure to return no content: it must then only return
   * an empty array, or an empty array with #cache set (with cacheability
   * metadata indicating the circumstances for it being empty).
   *
   * @return array
   *   A renderable array representing the content of the top bar item.
   */
  public function build();

}