class LayoutBuilderUiCacheContext

Same name in other branches
  1. 9 core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext
  2. 8.9.x core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext
  3. 10 core/modules/layout_builder/src/Cache/LayoutBuilderUiCacheContext.php \Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext

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

Cache context ID: 'route.name.is_layout_builder_ui'.

@internal Tagged services are internal.

Hierarchy

Expanded class hierarchy of LayoutBuilderUiCacheContext

1 string reference to 'LayoutBuilderUiCacheContext'
layout_builder.services.yml in core/modules/layout_builder/layout_builder.services.yml
core/modules/layout_builder/layout_builder.services.yml
1 service uses LayoutBuilderUiCacheContext
cache_context.route.name.is_layout_builder_ui in core/modules/layout_builder/layout_builder.services.yml
Drupal\layout_builder\Cache\LayoutBuilderUiCacheContext

File

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

Namespace

Drupal\layout_builder\Cache
View source
class LayoutBuilderUiCacheContext extends RouteNameCacheContext {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Layout Builder user interface');
    }
    
    /**
     * {@inheritdoc}
     */
    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';
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
LayoutBuilderUiCacheContext::getContext public function Returns the string representation of the cache context. Overrides RouteNameCacheContext::getContext
LayoutBuilderUiCacheContext::getLabel public static function Returns the label of the cache context. Overrides RouteNameCacheContext::getLabel
RouteCacheContext::$routeMatch protected property The route match.
RouteCacheContext::getCacheableMetadata public function Gets the cacheability metadata for the context. Overrides CacheContextInterface::getCacheableMetadata
RouteCacheContext::__construct public function Constructs a new RouteCacheContext class.

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