function LayoutBuilderHooks::entityBuildDefaultsAlter

Implements hook_entity_build_defaults_alter().

File

core/modules/layout_builder/src/Hook/LayoutBuilderHooks.php, line 182

Class

LayoutBuilderHooks
Hook implementations for layout_builder.

Namespace

Drupal\layout_builder\Hook

Code

public function entityBuildDefaultsAlter(array &$build, EntityInterface $entity, $view_mode) : void {
    // Contextual links are removed for entities viewed in Layout Builder's UI.
    // The route.name.is_layout_builder_ui cache context accounts for this
    // difference.
    // @see layout_builder_entity_view_alter()
    // @see \Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext
    $build['#cache']['contexts'][] = 'route.name.is_layout_builder_ui';
}

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