interface PageVariantInterface

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

Provides an interface for PageDisplayVariant plugins.

Page display variants are a specific type of DisplayVariant, intended for "pages", which always have some main content to be rendered. Hence page display variants may choose to render that main content in a certain way: decorated in a certain way, laid out in a certain way, et cetera.

For example, the \Drupal\block\Plugin\DisplayVariant\FullPageVariant page display variant is used by the Block module to control regions and output blocks placed in those regions.

Hierarchy

Expanded class hierarchy of PageVariantInterface

All classes that implement PageVariantInterface

See also

\Drupal\Core\Display\Attribute\DisplayVariant

\Drupal\Core\Display\VariantBase

\Drupal\Core\Display\VariantManager

Plugin API

4 files declare their use of PageVariantInterface
BlockPageVariant.php in core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php
HtmlRenderer.php in core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php
SimplePageVariant.php in core/lib/Drupal/Core/Render/Plugin/DisplayVariant/SimplePageVariant.php
TestDisplayVariant.php in core/modules/system/tests/modules/display_variant_test/src/Plugin/DisplayVariant/TestDisplayVariant.php

File

core/lib/Drupal/Core/Display/PageVariantInterface.php, line 22

Namespace

Drupal\Core\Display
View source
interface PageVariantInterface extends VariantInterface {
    
    /**
     * Sets the main content for the page being rendered.
     *
     * @param array $main_content
     *   The render array representing the main content.
     *
     * @return $this
     */
    public function setMainContent(array $main_content);
    
    /**
     * Sets the title for the page being rendered.
     *
     * @param string|array $title
     *   The page title: either a string for plain titles or a render array for
     *   formatted titles.
     *
     * @return $this
     */
    public function setTitle($title);

}

Members

Title Sort descending Modifiers Object type Summary Overrides
CacheableDependencyInterface::getCacheContexts public function The cache contexts associated with this object. 34
CacheableDependencyInterface::getCacheMaxAge public function The maximum age for which this object may be cached. 34
CacheableDependencyInterface::getCacheTags public function The cache tags associated with this object. 27
ConfigurableInterface::defaultConfiguration public function Gets default configuration for this plugin. 13
ConfigurableInterface::getConfiguration public function Gets this plugin's configuration. 13
ConfigurableInterface::setConfiguration public function Sets the configuration for this plugin instance. 13
DependentPluginInterface::calculateDependencies public function Calculates dependencies for the configured plugin. 19
PageVariantInterface::setMainContent public function Sets the main content for the page being rendered. 3
PageVariantInterface::setTitle public function Sets the title for the page being rendered. 3
PluginFormInterface::buildConfigurationForm public function Form constructor. 31
PluginFormInterface::submitConfigurationForm public function Form submission handler. 29
PluginFormInterface::validateConfigurationForm public function Form validation handler. 16
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 6
PluginInspectionInterface::getPluginId public function Gets the plugin ID of the plugin instance. 2
RefinableCacheableDependencyInterface::addCacheableDependency public function Adds a dependency on an object: merges its cacheability metadata. 1
RefinableCacheableDependencyInterface::addCacheContexts public function Adds cache contexts. 1
RefinableCacheableDependencyInterface::addCacheTags public function Adds cache tags. 1
RefinableCacheableDependencyInterface::mergeCacheMaxAge public function Merges the maximum age (in seconds) with the existing maximum age. 1
VariantInterface::access public function Determines if this display variant is accessible. 1
VariantInterface::adminLabel public function Returns the admin-facing display variant label. 1
VariantInterface::build public function Builds and returns the renderable array for the display variant. 3
VariantInterface::getWeight public function Returns the weight of the display variant. 1
VariantInterface::id public function Returns the unique ID for the display variant. 1
VariantInterface::label public function Returns the user-facing display variant label. 1
VariantInterface::setWeight public function Sets the weight of the display variant. 1

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