Skip to content

LayoutBuilderHooks

Layout Builder hooks for the Helper module.


  • Full name: \Drupal\helper\Hook\LayoutBuilderHooks

Properties

currentEntity

protected \Drupal\helper\CurrentEntity $currentEntity

moduleHandler

protected \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler

entityDisplayRepository

protected \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entityDisplayRepository

layoutBuilder

protected ?\Drupal\helper\LayoutBuilder $layoutBuilder

Methods

__construct

LayoutBuilderHooks constructor.

public __construct(\Drupal\helper\CurrentEntity $currentEntity, \Drupal\Core\Extension\ModuleHandlerInterface $moduleHandler, \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entityDisplayRepository, \Drupal\helper\LayoutBuilder|null $layoutBuilder = null): mixed

Parameters:

Parameter Type Description
$currentEntity \Drupal\helper\CurrentEntity
The current entity helper.
$moduleHandler \Drupal\Core\Extension\ModuleHandlerInterface
The module handler.
$entityDisplayRepository \Drupal\Core\Entity\EntityDisplayRepositoryInterface
The entity display repository.
$layoutBuilder \Drupal\helper\LayoutBuilder|null
The Layout Builder helper.

entityOperation

Implements hook_entity_operation().

public entityOperation(\Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Cache\CacheableMetadata $cacheability): array

Parameters:

Parameter Type Description
$entity \Drupal\Core\Entity\EntityInterface
$cacheability \Drupal\Core\Cache\CacheableMetadata

Implements template_preprocess_links().

public preprocessLinks(array& $variables): void

Parameters:

Parameter Type Description
$variables array

alterNavigationContentTop

Implements hook_preprocess_top_bar_page_actions().

public alterNavigationContentTop(array& $variables): void

If the current entity has a layout override, replace the existing featured page action with the Layout Builder page action.

Parameters:

Parameter Type Description
$variables array

alterLayoutForm

Implements hook_form_FORM_ID_alter().

public alterLayoutForm(mixed& $form, \Drupal\Core\Form\FormStateInterface $form_state): void

Add inline block validation to: - View mode layout builder default forms. - Layout library entity forms.

Parameters:

Parameter Type Description
$form mixed
$form_state \Drupal\Core\Form\FormStateInterface

validateNoInlineBlocks

Form validation; prevent saving a layout builder form with inline blocks.

public validateNoInlineBlocks(mixed& $form, \Drupal\Core\Form\FormStateInterface $form_state): void

Parameters:

Parameter Type Description
$form mixed
$form_state \Drupal\Core\Form\FormStateInterface

alterPluginFilterBlock

Implements hook_plugin_filter_TYPE_alter().

public alterPluginFilterBlock(array& $definitions, array $extra, string $consumer): void

Parameters:

Parameter Type Description
$definitions array
$extra array
$consumer string

alterPluginFilterLayout

Implements hook_plugin_filter_TYPE_alter().

public alterPluginFilterLayout(array& $definitions): void

Parameters:

Parameter Type Description
$definitions array

alterLayouts

Implements hook_layout_alter().

public alterLayouts(array& $definitions): void

Parameters:

Parameter Type Description
$definitions array