Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DisplayVariant.php

class DisplayVariant

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Display/Annotation/DisplayVariant.php \Drupal\Core\Display\Annotation\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

  • \Drupal\Core\Render\Plugin\DisplayVariant\SimplePageVariant
  • \Drupal\block\Plugin\DisplayVariant\BlockPageVariant

Hierarchy

  • class \Drupal\Component\Plugin\Attribute\AttributeBase implements \Drupal\Component\Plugin\Attribute\AttributeInterface
    • class \Drupal\Component\Plugin\Attribute\Plugin extends \Drupal\Component\Plugin\Attribute\AttributeBase
      • 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

1 file declares its use of DisplayVariant
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 Overriden Title Overrides
AttributeBase::$class protected property The class used for this attribute class.
AttributeBase::$provider protected property The provider of the attribute class.
AttributeBase::get public function Gets the value of an attribute. Overrides AttributeInterface::get 6
AttributeBase::getClass public function Gets the class of the attribute class. Overrides AttributeInterface::getClass 1
AttributeBase::getId public function Gets the unique ID for this attribute class. Overrides AttributeInterface::getId
AttributeBase::getProvider public function Gets the name of the provider of the attribute class. Overrides AttributeInterface::getProvider
AttributeBase::setClass public function Sets the class of the attributed class. Overrides AttributeInterface::setClass 1
AttributeBase::setProvider public function Sets the name of the provider of the attribute class. Overrides AttributeInterface::setProvider
DisplayVariant::__construct public function Constructs a DisplayVariant plugin attribute object. Overrides Plugin::__construct

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal