class DisplayVariant

Same name in other branches
  1. 9 core/lib/Drupal/Core/Display/Annotation/DisplayVariant.php \Drupal\Core\Display\Annotation\DisplayVariant
  2. 8.9.x core/lib/Drupal/Core/Display/Annotation/DisplayVariant.php \Drupal\Core\Display\Annotation\DisplayVariant
  3. 11.x core/lib/Drupal/Core/Display/Annotation/DisplayVariant.php \Drupal\Core\Display\Annotation\DisplayVariant
  4. 11.x core/lib/Drupal/Core/Display/Attribute/DisplayVariant.php \Drupal\Core\Display\Attribute\DisplayVariant

Defines a display variant attribute object.

Display variants are used to dictate the output of a given Display, which can be used to control the output of many parts of Drupal.

Variants are usually chosen by some selection criteria, and are instantiated directly. Each variant must define its own approach to rendering, and can either load its own data or be injected with data from another Display object.

Plugin namespace: Plugin\DisplayVariant

For working examples, see

Attributes

#[\Attribute(\Attribute::TARGET_CLASS)]

Hierarchy

  • class \Drupal\Core\Display\Attribute\DisplayVariant extends \Drupal\Component\Plugin\Attribute\Plugin

Expanded class hierarchy of DisplayVariant

See also

\Drupal\Core\Display\VariantInterface

\Drupal\Core\Display\VariantBase

\Drupal\Core\Display\VariantManager

\Drupal\Core\Display\PageVariantInterface

Plugin API

2 files declare their use of DisplayVariant
TestDisplayVariant.php in core/modules/system/tests/modules/display_variant_test/src/Plugin/DisplayVariant/TestDisplayVariant.php
VariantManager.php in core/lib/Drupal/Core/Display/VariantManager.php

File

core/lib/Drupal/Core/Display/Attribute/DisplayVariant.php, line 31

Namespace

Drupal\Core\Display\Attribute
View source
class DisplayVariant extends Plugin {
    
    /**
     * Constructs a DisplayVariant plugin attribute object.
     *
     * @param string $id
     *   The plugin ID.
     * @param \Drupal\Core\StringTranslation\TranslatableMarkup $admin_label
     *   The administrative label.
     * @param class-string|null $deriver
     *   (optional) The deriver class.
     */
    public function __construct(string $id, TranslatableMarkup $admin_label, ?string $deriver = NULL) {
    }

}

Members

Title Sort descending Modifiers Object type Summary
DisplayVariant::__construct public function Constructs a DisplayVariant plugin attribute object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.