class DenyNodePreview
Same name in other branches
- 9 core/modules/node/src/PageCache/DenyNodePreview.php \Drupal\node\PageCache\DenyNodePreview
- 8.9.x core/modules/node/src/PageCache/DenyNodePreview.php \Drupal\node\PageCache\DenyNodePreview
- 10 core/modules/node/src/PageCache/DenyNodePreview.php \Drupal\node\PageCache\DenyNodePreview
Cache policy for node preview page.
This policy rule denies caching of responses generated by the entity.node.preview route.
Hierarchy
- class \Drupal\node\PageCache\DenyNodePreview implements \Drupal\Core\PageCache\ResponsePolicyInterface
Expanded class hierarchy of DenyNodePreview
1 file declares its use of DenyNodePreview
- DenyNodePreviewTest.php in core/
modules/ node/ tests/ src/ Unit/ PageCache/ DenyNodePreviewTest.php
1 string reference to 'DenyNodePreview'
- node.services.yml in core/
modules/ node/ node.services.yml - core/modules/node/node.services.yml
1 service uses DenyNodePreview
File
-
core/
modules/ node/ src/ PageCache/ DenyNodePreview.php, line 16
Namespace
Drupal\node\PageCacheView source
class DenyNodePreview implements ResponsePolicyInterface {
/**
* The current route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Constructs a deny node preview page cache policy.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
*/
public function __construct(RouteMatchInterface $route_match) {
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*/
public function check(Response $response, Request $request) {
if ($this->routeMatch
->getRouteName() === 'entity.node.preview') {
return static::DENY;
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
DenyNodePreview::$routeMatch | protected | property | The current route match. | |
DenyNodePreview::check | public | function | Overrides ResponsePolicyInterface::check | |
DenyNodePreview::__construct | public | function | Constructs a deny node preview page cache policy. | |
ResponsePolicyInterface::DENY | constant | Deny storage of a page in the cache. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.