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

Breadcrumb

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

class Layout

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Layout/Annotation/Layout.php \Drupal\Core\Layout\Annotation\Layout

Defines a Layout attribute object.

Layouts are used to define a list of regions and then output render arrays in each of the regions, usually using a template.

Plugin Namespace: Plugin\Layout

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\Layout\Attribute\Layout extends \Drupal\Component\Plugin\Attribute\Plugin

Expanded class hierarchy of Layout

See also

\Drupal\Core\Layout\LayoutInterface

\Drupal\Core\Layout\LayoutDefault

\Drupal\Core\Layout\LayoutPluginManager

Plugin API

2 files declare their use of Layout
BlankLayout.php in core/modules/layout_builder/src/Plugin/Layout/BlankLayout.php
LayoutPluginManager.php in core/lib/Drupal/Core/Layout/LayoutPluginManager.php
10 string references to 'Layout'
field.field.node.article.layout_builder__layout.yml in core/profiles/demo_umami/config/install/field.field.node.article.layout_builder__layout.yml
core/profiles/demo_umami/config/install/field.field.node.article.layout_builder__layout.yml
field.field.node.page.layout_builder__layout.yml in core/profiles/demo_umami/config/install/field.field.node.page.layout_builder__layout.yml
core/profiles/demo_umami/config/install/field.field.node.page.layout_builder__layout.yml
field.field.node.recipe.layout_builder__layout.yml in core/profiles/demo_umami/config/install/field.field.node.recipe.layout_builder__layout.yml
core/profiles/demo_umami/config/install/field.field.node.recipe.layout_builder__layout.yml
LayoutBuilderEntityViewDisplay::addSectionField in core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
Adds a layout section field to a given bundle.
LayoutBuilderEntityViewDisplayForm::copyFormValuesToEntity in core/modules/layout_builder/src/Form/LayoutBuilderEntityViewDisplayForm.php
Copies top-level form values to entity properties.

... See full list

File

core/lib/Drupal/Core/Layout/Attribute/Layout.php, line 23

Namespace

Drupal\Core\Layout\Attribute
View source
class Layout extends Plugin {
    
    /**
     * Any additional properties and values.
     *
     * @var array
     *
     * @see \Drupal\Core\Layout\LayoutDefinition::$additional
     */
    public readonly array $additional;
    
    /**
     * Constructs a Layout attribute.
     *
     * @param string $id
     *   The plugin ID.
     * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $label
     *   (optional) The human-readable name. @todo Deprecate optional label in
     *   https://www.drupal.org/project/drupal/issues/3392572.
     * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $category
     *   (optional) The human-readable category. @todo Deprecate optional category
     *   in https://www.drupal.org/project/drupal/issues/3392572.
     * @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
     *   (optional) The description for advanced layouts.
     * @param string|null $template
     *   (optional) The template file to render the layout.
     * @param string $theme_hook
     *   (optional) The template hook to render the layout.
     * @param string|null $path
     *   (optional) Path (relative to the module or theme) to resources like icon or template.
     * @param string|null $library
     *   (optional) The asset library.
     * @param string|null $icon
     *   (optional) The path to the preview image (relative to the 'path' given).
     * @param string[][]|null $icon_map
     *   (optional) The icon map.
     * @param array $regions
     *   (optional) An associative array of regions in this layout.
     * @param string|null $default_region
     *   (optional) The default region.
     * @param class-string $class
     *   (optional) The layout plugin class.
     * @param \Drupal\Core\Plugin\Context\ContextDefinitionInterface[] $context_definitions
     *   (optional) The context definition.
     * @param array $config_dependencies
     *   (optional) The config dependencies.
     * @param class-string|null $deriver
     *   (optional) The deriver class.
     * @param mixed $additional
     *   (optional) Additional properties passed in that can be used by a deriver.
     */
    public function __construct(string $id, ?TranslatableMarkup $label = NULL, ?TranslatableMarkup $category = NULL, ?TranslatableMarkup $description = NULL, ?string $template = NULL, string $theme_hook = 'layout', ?string $path = NULL, ?string $library = NULL, ?string $icon = NULL, ?array $icon_map = NULL, array $regions = [], ?string $default_region = NULL, string $class = LayoutDefault::class, array $context_definitions = [], array $config_dependencies = [], ?string $deriver = NULL, ...$additional) {
        // Layout definitions support arbitrary properties being passed in, which
        // are stored in the 'additional' property in LayoutDefinition. The variadic
        // 'additional' parameter here saves arbitrary parameters passed into the
        // 'additional' property in this attribute class. The 'additional' property
        // gets passed to the LayoutDefinition constructor in ::get().
        // @see \Drupal\Core\Layout\LayoutDefinition::$additional
        // @see \Drupal\Core\Layout\LayoutDefinition::get()
        $this->additional = $additional;
    }
    
    /**
     * {@inheritdoc}
     */
    public function get() : LayoutDefinition {
        return new LayoutDefinition(parent::get());
    }

}

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::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
Layout::$additional public property Any additional properties and values.
Layout::get public function Gets the value of an attribute. Overrides AttributeBase::get
Layout::__construct public function Constructs a Layout attribute. Overrides Plugin::__construct

API Navigation

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