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