blob: ded7d58162f938007ff14ad41c824455af112587 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php
namespace Drupal\layout_builder\Cache;
use Drupal\Core\Cache\Context\RouteNameCacheContext;
/**
* 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.
*/
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';
}
}
|