Layout.php

Same filename in this branch
  1. 11.x core/lib/Drupal/Core/Layout/Annotation/Layout.php
Same filename and directory in other branches
  1. 9 core/lib/Drupal/Core/Layout/Annotation/Layout.php
  2. 8.9.x core/lib/Drupal/Core/Layout/Annotation/Layout.php
  3. 10 core/lib/Drupal/Core/Layout/Annotation/Layout.php

Namespace

Drupal\Core\Layout\Attribute

File

core/lib/Drupal/Core/Layout/Attribute/Layout.php

View source
<?php

namespace Drupal\Core\Layout\Attribute;

use Drupal\Component\Plugin\Attribute\Plugin;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Layout\LayoutDefault;
use Drupal\Core\Layout\LayoutDefinition;

/**
 * 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
 *
 * @see \Drupal\Core\Layout\LayoutInterface
 * @see \Drupal\Core\Layout\LayoutDefault
 * @see \Drupal\Core\Layout\LayoutPluginManager
 * @see plugin_api
 */
class Layout extends Plugin {
    
    /**
     * Any additional properties and values.
     *
     * @see \Drupal\Core\Layout\LayoutDefinition::$additional
     *
     * @var array
     */
    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());
    }

}

Classes

Title Deprecated Summary
Layout Defines a Layout attribute object.

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