class LayoutDefinition extends PluginDefinition implements PluginDefinitionInterface, DerivablePluginDefinitionInterface, DependentPluginDefinitionInterface, ContextAwarePluginDefinitionInterface (View source)

Provides an implementation of a layout definition and its metadata.

Traits

Provides a trait for context-aware object-based plugin definitions.

Provides a trait for a plugin definition that has dependencies.

Properties

protected string $id

The plugin ID.

from  PluginDefinition
protected string $class

A fully qualified class name.

from  PluginDefinition
protected string $provider

The plugin provider.

from  PluginDefinition
protected ContextDefinitionInterface[] $contextDefinitions

The context definitions for this plugin definition.

from  ContextAwarePluginDefinitionTrait
protected array $config_dependencies

The dependencies of this plugin definition.

from  DependentPluginDefinitionTrait
protected string|null $deriver

The name of the deriver of this layout definition, if any.

protected string $label

The human-readable name.

protected string $description

An optional description for advanced layouts.

protected string $category

The human-readable category.

protected string|null $template

The template file to render this layout (relative to the 'path' given).

protected string $templatePath

The path to the template.

protected string|null $theme_hook

The theme hook used to render this layout.

protected string $path

Path (relative to the module or theme) to resources like icon or template.

protected string|null $library

The asset library.

protected string $icon

The path to the preview image.

protected string[][]|null $icon_map

An array defining the regions of a layout.

protected array $regions

An associative array of regions in this layout.

protected string $default_region

The default region.

protected array $additional

Any additional properties and values.

Methods

string
id()

Gets the unique identifier of the plugin.

setClass(string $class)

Sets the class.

string
getClass()

Gets the class.

string
getProvider()

Gets the plugin provider.

hasContextDefinition($name)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::hasContextDefinition().

getContextDefinitions()

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinitions().

getContextDefinition($name)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinition().

addContextDefinition($name, ContextDefinitionInterface $definition)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::addContextDefinition().

removeContextDefinition($name)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::removeContextDefinition().

setConfigDependencies(array $config_dependencies)

{@inheritdoc}

__construct(array $definition)

LayoutDefinition constructor.

mixed
get(string $property)

Gets any arbitrary property.

$this
set(string $property, mixed $value)

Sets a value to an arbitrary property.

getLabel()

Gets the human-readable name of the layout definition.

$this
setLabel(string|TranslatableMarkup $label)

Sets the human-readable name of the layout definition.

getDescription()

Gets the description of the layout definition.

$this
setDescription(string|TranslatableMarkup $description)

Sets the description of the layout definition.

getCategory()

Gets the human-readable category of the layout definition.

$this
setCategory(string|TranslatableMarkup $category)

Sets the human-readable category of the layout definition.

string|null
getTemplate()

Gets the template name.

$this
setTemplate(string|null $template)

Sets the template name.

string
getTemplatePath()

Gets the template path.

$this
setTemplatePath(string $template_path)

Sets the template path.

string|null
getThemeHook()

Gets the theme hook.

$this
setThemeHook(string $theme_hook)

Sets the theme hook.

string
getPath()

Gets the base path for this layout definition.

$this
setPath(string $path)

Sets the base path for this layout definition.

string|null
getLibrary()

Gets the asset library for this layout definition.

$this
setLibrary(string|null $library)

Sets the asset library for this layout definition.

string|null
getIconPath()

Gets the icon path for this layout definition.

$this
setIconPath(string|null $icon)

Sets the icon path for this layout definition.

string[][]|null
getIconMap()

Gets the icon map for this layout definition.

$this
setIconMap(string[][]|null $icon_map)

Sets the icon map for this layout definition.

array
getIcon(int $width = 125, int $height = 150, int $stroke_width = NULL, int $padding = NULL)

Builds a render array for an icon representing the layout.

getIconBuilder()

Wraps the icon builder.

array[]
getRegions()

Gets the regions for this layout definition.

$this
setRegions(array $regions)

Sets the regions for this layout definition.

string[]
getRegionNames()

Gets the machine-readable region names.

string[]
getRegionLabels()

Gets the human-readable region labels.

string
getDefaultRegion()

Gets the default region.

$this
setDefaultRegion(string $default_region)

Sets the default region.

string|null
getDeriver()

Gets the name of the deriver of this plugin definition, if it exists.

$this
setDeriver(string|null $deriver)

Sets the deriver of this plugin definition.

Details

string id()

Gets the unique identifier of the plugin.

Return Value

string

The unique identifier of the plugin.

PluginDefinitionInterface setClass(string $class)

Sets the class.

Parameters

string $class

A fully qualified class name.

Return Value

PluginDefinitionInterface

Exceptions

InvalidArgumentException

string getClass()

Gets the class.

Return Value

string

A fully qualified class name.

string getProvider()

Gets the plugin provider.

The provider is the name of the module that provides the plugin, or "core', or "component".

Return Value

string

The provider.

hasContextDefinition($name)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::hasContextDefinition().

Parameters

$name

getContextDefinitions()

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinitions().

getContextDefinition($name)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinition().

Parameters

$name

addContextDefinition($name, ContextDefinitionInterface $definition)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::addContextDefinition().

Parameters

$name
ContextDefinitionInterface $definition

removeContextDefinition($name)

Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::removeContextDefinition().

Parameters

$name

getConfigDependencies()

{@inheritdoc}

setConfigDependencies(array $config_dependencies)

{@inheritdoc}

Parameters

array $config_dependencies

__construct(array $definition)

LayoutDefinition constructor.

Parameters

array $definition

An array of values from the annotation.

mixed get(string $property)

Gets any arbitrary property.

Parameters

string $property

The property to retrieve.

Return Value

mixed

The value for that property, or NULL if the property does not exist.

$this set(string $property, mixed $value)

Sets a value to an arbitrary property.

Parameters

string $property

The property to use for the value.

mixed $value

The value to set.

Return Value

$this

string|TranslatableMarkup getLabel()

Gets the human-readable name of the layout definition.

Return Value

string|TranslatableMarkup

The human-readable name of the layout definition.

$this setLabel(string|TranslatableMarkup $label)

Sets the human-readable name of the layout definition.

Parameters

string|TranslatableMarkup $label

The human-readable name of the layout definition.

Return Value

$this

string|TranslatableMarkup getDescription()

Gets the description of the layout definition.

Return Value

string|TranslatableMarkup

The description of the layout definition.

$this setDescription(string|TranslatableMarkup $description)

Sets the description of the layout definition.

Parameters

string|TranslatableMarkup $description

The description of the layout definition.

Return Value

$this

string|TranslatableMarkup getCategory()

Gets the human-readable category of the layout definition.

Return Value

string|TranslatableMarkup

The human-readable category of the layout definition.

$this setCategory(string|TranslatableMarkup $category)

Sets the human-readable category of the layout definition.

Parameters

string|TranslatableMarkup $category

The human-readable category of the layout definition.

Return Value

$this

string|null getTemplate()

Gets the template name.

Return Value

string|null

The template name, if it exists.

$this setTemplate(string|null $template)

Sets the template name.

Parameters

string|null $template

The template name.

Return Value

$this

string getTemplatePath()

Gets the template path.

Return Value

string

The template path.

$this setTemplatePath(string $template_path)

Sets the template path.

Parameters

string $template_path

The template path.

Return Value

$this

string|null getThemeHook()

Gets the theme hook.

Return Value

string|null

The theme hook, if it exists.

$this setThemeHook(string $theme_hook)

Sets the theme hook.

Parameters

string $theme_hook

The theme hook.

Return Value

$this

string getPath()

Gets the base path for this layout definition.

Return Value

string

The base path.

$this setPath(string $path)

Sets the base path for this layout definition.

Parameters

string $path

The base path.

Return Value

$this

string|null getLibrary()

Gets the asset library for this layout definition.

Return Value

string|null

The asset library, if it exists.

$this setLibrary(string|null $library)

Sets the asset library for this layout definition.

Parameters

string|null $library

The asset library.

Return Value

$this

string|null getIconPath()

Gets the icon path for this layout definition.

Return Value

string|null

The icon path, if it exists.

$this setIconPath(string|null $icon)

Sets the icon path for this layout definition.

Parameters

string|null $icon

The icon path.

Return Value

$this

string[][]|null getIconMap()

Gets the icon map for this layout definition.

This should not be used if an icon path is specified. See ::getIcon().

Return Value

string[][]|null

The icon map, if it exists.

$this setIconMap(string[][]|null $icon_map)

Sets the icon map for this layout definition.

Parameters

string[][]|null $icon_map

The icon map.

Return Value

$this

array getIcon(int $width = 125, int $height = 150, int $stroke_width = NULL, int $padding = NULL)

Builds a render array for an icon representing the layout.

Parameters

int $width

(optional) The width of the icon. Defaults to 125.

int $height

(optional) The height of the icon. Defaults to 150.

int $stroke_width

(optional) If an icon map is used, the width of region borders.

int $padding

(optional) If an icon map is used, the padding between regions. Any value above 0 is valid.

Return Value

array

A render array for the icon.

protected IconBuilderInterface getIconBuilder()

Wraps the icon builder.

Return Value

IconBuilderInterface

The icon builder.

array[] getRegions()

Gets the regions for this layout definition.

Return Value

array[]

The layout regions. The keys of the array are the machine names of the regions, and the values are an associative array with the following keys:

  • label: (string) The human-readable name of the region. Any remaining keys may have special meaning for the given layout plugin, but are undefined here.

$this setRegions(array $regions)

Sets the regions for this layout definition.

Parameters

array $regions

An array of regions, see ::getRegions() for the format.

Return Value

$this

string[] getRegionNames()

Gets the machine-readable region names.

Return Value

string[]

An array of machine-readable region names.

string[] getRegionLabels()

Gets the human-readable region labels.

Return Value

string[]

An array of human-readable region labels.

string getDefaultRegion()

Gets the default region.

Return Value

string

The machine-readable name of the default region.

$this setDefaultRegion(string $default_region)

Sets the default region.

Parameters

string $default_region

The machine-readable name of the default region.

Return Value

$this

string|null getDeriver()

Gets the name of the deriver of this plugin definition, if it exists.

Return Value

string|null

Either the deriver class name, or NULL if the plugin is not derived.

$this setDeriver(string|null $deriver)

Sets the deriver of this plugin definition.

Parameters

string|null $deriver

Either the name of a class that implements \Drupal\Component\Plugin\Derivative\DeriverInterface, or NULL.

Return Value

$this