trait LayoutEntityHelperTrait (View source)

Methods to help with entities using the layout builder.

Properties

protected SectionStorageManagerInterface $sectionStorageManager

The section storage manager.

Methods

bool
isLayoutCompatibleEntity(EntityInterface $entity)

Determines if an entity can have a layout.

int[]
getInlineBlockRevisionIdsInSections(array $sections)

Gets revision IDs for layout sections.

getEntitySections(EntityInterface $entity)

Gets the sections for an entity if any.

getInlineBlockComponents(array $sections)

Gets components that have Inline Block plugins.

getSectionStorageForEntity(EntityInterface $entity)

Gets the section storage for an entity.

bool
isEntityUsingFieldOverride(EntityInterface $entity) deprecated

Determines if an entity is using a field for the layout override.

bool
originalEntityUsesDefaultStorage(EntityInterface $entity)

Determines if the original entity used the default section storage.

Details

protected bool isLayoutCompatibleEntity(EntityInterface $entity)

Determines if an entity can have a layout.

Parameters

EntityInterface $entity

The entity to check.

Return Value

bool

TRUE if the entity can have a layout otherwise FALSE.

protected int[] getInlineBlockRevisionIdsInSections(array $sections)

Gets revision IDs for layout sections.

Parameters

array $sections

The layout sections.

Return Value

int[]

The revision IDs.

protected Section[] getEntitySections(EntityInterface $entity)

Gets the sections for an entity if any.

Parameters

EntityInterface $entity

The entity.

Return Value

Section[]

The entity layout sections if available.

protected SectionComponent[] getInlineBlockComponents(array $sections)

Gets components that have Inline Block plugins.

Parameters

array $sections

The layout sections.

Return Value

SectionComponent[]

The components that contain Inline Block plugins.

protected SectionStorageInterface|null getSectionStorageForEntity(EntityInterface $entity)

Gets the section storage for an entity.

Parameters

EntityInterface $entity

The entity.

Return Value

SectionStorageInterface|null

The section storage if found otherwise NULL.

protected bool isEntityUsingFieldOverride(EntityInterface $entity) deprecated

deprecated in drupal:8.7.0 and is removed from drupal:9.0.0. To determine if an entity has a layout override, use \Drupal\layout_builder\LayoutEntityHelperTrait::getSectionStorageForEntity() and check whether the result is an instance of \Drupal\layout_builder\DefaultsSectionStorageInterface.

Determines if an entity is using a field for the layout override.

Parameters

EntityInterface $entity

The entity.

Return Value

bool

TRUE if the entity is using a field for a layout override.

See also

https://www.drupal.org/node/3030609

protected bool originalEntityUsesDefaultStorage(EntityInterface $entity)

Determines if the original entity used the default section storage.

This method can be used during the entity save process to determine whether $entity->original is set and used the default section storage plugin as determined by ::getSectionStorageForEntity().

Parameters

EntityInterface $entity

The entity.

Return Value

bool

TRUE if the original entity used the default storage.