function LayoutBuilderUiCacheContext::getContext

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext::getContext()
  2. 8.9.x core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext::getContext()
  3. 10 core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext::getContext()

Overrides RouteNameCacheContext::getContext

File

core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php, line 27

Class

LayoutBuilderUiCacheContext
Determines if an entity is being viewed in the Layout Builder UI.

Namespace

Drupal\layout_builder\Cache

Code

public function getContext() {
    $route_name = $this->routeMatch
        ->getRouteName();
    if ($route_name && str_starts_with($route_name, 'layout_builder.')) {
        return 'is_layout_builder_ui.0';
    }
    return 'is_layout_builder_ui.1';
}

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