DenyAdminRoutes.php in Drupal 9
File
core/modules/dynamic_page_cache/src/PageCache/ResponsePolicy/DenyAdminRoutes.php
View source
<?php
namespace Drupal\dynamic_page_cache\PageCache\ResponsePolicy;
use Drupal\Core\PageCache\ResponsePolicyInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class DenyAdminRoutes implements ResponsePolicyInterface {
protected $routeMatch;
public function __construct(RouteMatchInterface $route_match) {
$this->routeMatch = $route_match;
}
public function check(Response $response, Request $request) {
if (($route = $this->routeMatch
->getRouteObject()) && $route
->getOption('_admin_route')) {
return static::DENY;
}
}
}