annotate core/modules/node/src/PageCache/DenyNodePreview.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\node\PageCache;
Chris@0 4
Chris@0 5 use Drupal\Core\PageCache\ResponsePolicyInterface;
Chris@0 6 use Drupal\Core\Routing\RouteMatchInterface;
Chris@0 7 use Symfony\Component\HttpFoundation\Request;
Chris@0 8 use Symfony\Component\HttpFoundation\Response;
Chris@0 9
Chris@0 10 /**
Chris@0 11 * Cache policy for node preview page.
Chris@0 12 *
Chris@0 13 * This policy rule denies caching of responses generated by the
Chris@0 14 * entity.node.preview route.
Chris@0 15 */
Chris@0 16 class DenyNodePreview implements ResponsePolicyInterface {
Chris@0 17
Chris@0 18 /**
Chris@0 19 * The current route match.
Chris@0 20 *
Chris@0 21 * @var \Drupal\Core\Routing\RouteMatchInterface
Chris@0 22 */
Chris@0 23 protected $routeMatch;
Chris@0 24
Chris@0 25 /**
Chris@0 26 * Constructs a deny node preview page cache policy.
Chris@0 27 *
Chris@0 28 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
Chris@0 29 * The current route match.
Chris@0 30 */
Chris@0 31 public function __construct(RouteMatchInterface $route_match) {
Chris@0 32 $this->routeMatch = $route_match;
Chris@0 33 }
Chris@0 34
Chris@0 35 /**
Chris@0 36 * {@inheritdoc}
Chris@0 37 */
Chris@0 38 public function check(Response $response, Request $request) {
Chris@0 39 if ($this->routeMatch->getRouteName() === 'entity.node.preview') {
Chris@0 40 return static::DENY;
Chris@0 41 }
Chris@0 42 }
Chris@0 43
Chris@0 44 }