3 namespace Drupal\Core\Display;
5 use Drupal\Component\Plugin\ConfigurablePluginInterface;
6 use Drupal\Component\Plugin\PluginInspectionInterface;
7 use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
8 use Drupal\Core\Plugin\PluginFormInterface;
9 use Drupal\Core\Session\AccountInterface;
12 * Provides an interface for DisplayVariant plugins.
14 * @see \Drupal\Core\Display\Annotation\DisplayVariant
15 * @see \Drupal\Core\Display\VariantBase
16 * @see \Drupal\Core\Display\VariantManager
19 interface VariantInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface, RefinableCacheableDependencyInterface {
22 * Returns the user-facing display variant label.
25 * The display variant label.
27 public function label();
30 * Returns the admin-facing display variant label.
32 * This is for the type of display variant, not the configured variant itself.
35 * The display variant administrative label.
37 public function adminLabel();
40 * Returns the unique ID for the display variant.
43 * The display variant ID.
48 * Returns the weight of the display variant.
51 * The display variant weight.
53 public function getWeight();
56 * Sets the weight of the display variant.
61 public function setWeight($weight);
64 * Determines if this display variant is accessible.
66 * @param \Drupal\Core\Session\AccountInterface $account
67 * (optional) The user for which to check access, or NULL to check access
68 * for the current user. Defaults to NULL.
71 * TRUE if this display variant is accessible, FALSE otherwise.
73 public function access(AccountInterface $account = NULL);
76 * Builds and returns the renderable array for the display variant.
78 * The variant can contain cacheability metadata for the configuration that
79 * was passed in setConfiguration(). In the build() method, this should be
80 * added to the render array that is returned.
83 * A render array for the display variant.
85 public function build();