trait FieldLayoutEntityDisplayTrait (View source)

Provides shared code for entity displays.

Both EntityViewDisplay and EntityFormDisplay must maintain their parent hierarchy, while being identically enhanced by Field Layout. This trait contains the code they both share.

Methods

getLayoutDefinition(string $layout_id)

Gets a layout definition.

getLayoutId()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getLayoutId().

getLayoutSettings()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getLayoutSettings().

setLayoutId($layout_id, array $layout_settings = [])

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::setLayoutId().

setLayout(LayoutInterface $layout)

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::setLayout().

getLayout()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getLayout().

doGetLayout(string $layout_id, array $layout_settings)

Gets the layout plugin.

init()

Overrides \Drupal\Core\Entity\EntityDisplayBase::init().

preSave(EntityStorageInterface $storage)

Overrides \Drupal\Core\Entity\EntityDisplayBase::preSave().

ensureLayout($default_layout_id = 'layout_onecol')

{@inheritdoc}

calculateDependencies()

Overrides \Drupal\Core\Entity\EntityDisplayBase::calculateDependencies().

getDefaultRegion()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getDefaultRegion().

Details

protected LayoutDefinition getLayoutDefinition(string $layout_id)

Gets a layout definition.

Parameters

string $layout_id

The layout ID.

Return Value

LayoutDefinition

The layout definition.

getLayoutId()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getLayoutId().

getLayoutSettings()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getLayoutSettings().

setLayoutId($layout_id, array $layout_settings = [])

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::setLayoutId().

Parameters

$layout_id
array $layout_settings

setLayout(LayoutInterface $layout)

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::setLayout().

Parameters

LayoutInterface $layout

getLayout()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getLayout().

protected LayoutInterface doGetLayout(string $layout_id, array $layout_settings)

Gets the layout plugin.

Parameters

string $layout_id

A layout plugin ID.

array $layout_settings

An array of settings.

Return Value

LayoutInterface

The layout plugin.

protected init()

Overrides \Drupal\Core\Entity\EntityDisplayBase::init().

preSave(EntityStorageInterface $storage)

Overrides \Drupal\Core\Entity\EntityDisplayBase::preSave().

Parameters

EntityStorageInterface $storage

ensureLayout($default_layout_id = 'layout_onecol')

{@inheritdoc}

Parameters

$default_layout_id

calculateDependencies()

Overrides \Drupal\Core\Entity\EntityDisplayBase::calculateDependencies().

Ensure the plugin dependencies are included. Once layouts are no longer stored as third party settings, this will be handled by the code in \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies() that handles \Drupal\Core\Entity\EntityWithPluginCollectionInterface.

getDefaultRegion()

Implements \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface::getDefaultRegion().