Mercurial > hg > isophonics-drupal-site
comparison core/modules/node/src/PageCache/DenyNodePreview.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\node\PageCache; | |
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 node preview page. | |
12 * | |
13 * This policy rule denies caching of responses generated by the | |
14 * entity.node.preview route. | |
15 */ | |
16 class DenyNodePreview implements ResponsePolicyInterface { | |
17 | |
18 /** | |
19 * The current route match. | |
20 * | |
21 * @var \Drupal\Core\Routing\RouteMatchInterface | |
22 */ | |
23 protected $routeMatch; | |
24 | |
25 /** | |
26 * Constructs a deny node preview page cache policy. | |
27 * | |
28 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match | |
29 * The current route match. | |
30 */ | |
31 public function __construct(RouteMatchInterface $route_match) { | |
32 $this->routeMatch = $route_match; | |
33 } | |
34 | |
35 /** | |
36 * {@inheritdoc} | |
37 */ | |
38 public function check(Response $response, Request $request) { | |
39 if ($this->routeMatch->getRouteName() === 'entity.node.preview') { | |
40 return static::DENY; | |
41 } | |
42 } | |
43 | |
44 } |