Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / web / core / modules / dynamic_page_cache / src / PageCache / ResponsePolicy / DenyAdminRoutes.php
1 <?php
2
3 namespace Drupal\dynamic_page_cache\PageCache\ResponsePolicy;
4
5 use Drupal\Core\PageCache\ResponsePolicyInterface;
6 use Drupal\Core\Routing\RouteMatchInterface;
7 use Symfony\Component\HttpFoundation\Request;
8 use Symfony\Component\HttpFoundation\Response;
9
10 /**
11  * Cache policy for routes with the '_admin_route' option set.
12  *
13  * This policy rule denies caching of responses generated for admin routes,
14  * because admin routes have very low cache hit ratios due to low traffic and
15  * form submissions.
16  */
17 class DenyAdminRoutes implements ResponsePolicyInterface {
18
19   /**
20    * The current route match.
21    *
22    * @var \Drupal\Core\Routing\RouteMatchInterface
23    */
24   protected $routeMatch;
25
26   /**
27    * Constructs a deny admin route page cache policy.
28    *
29    * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
30    *   The current route match.
31    */
32   public function __construct(RouteMatchInterface $route_match) {
33     $this->routeMatch = $route_match;
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function check(Response $response, Request $request) {
40     if (($route = $this->routeMatch->getRouteObject()) && $route->getOption('_admin_route')) {
41       return static::DENY;
42     }
43   }
44
45 }