RouteAdminCacheContext.php in Responsive Theme Preview 8
File
src/Cache/RouteAdminCacheContext.php
View source
<?php
namespace Drupal\responsive_preview\Cache;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Cache\Context\CacheContextInterface;
use Drupal\Core\Routing\AdminContext;
class RouteAdminCacheContext implements CacheContextInterface {
protected $routeAdminContext;
public function __construct(AdminContext $route_admin_context) {
$this->routeAdminContext = $route_admin_context;
}
public static function getLabel() {
return t('Route is admin');
}
public function getContext() {
return $this->routeAdminContext
->isAdminRoute() ? '1' : '0';
}
public function getCacheableMetadata() {
return new CacheableMetadata();
}
}