function DenyNodePreview::check

Same name and namespace in other branches
  1. 8.9.x core/modules/node/src/PageCache/DenyNodePreview.php \Drupal\node\PageCache\DenyNodePreview::check()
  2. 10 core/modules/node/src/PageCache/DenyNodePreview.php \Drupal\node\PageCache\DenyNodePreview::check()
  3. 11.x core/modules/node/src/PageCache/DenyNodePreview.php \Drupal\node\PageCache\DenyNodePreview::check()

Determines whether it is save to store a page in the cache.

Parameters

\Symfony\Component\HttpFoundation\Response $response: The response which is about to be sent to the client.

\Symfony\Component\HttpFoundation\Request $request: The request object.

Return value

string|null Either static::DENY or NULL. Calling code may attempt to store a page in the cache unless static::DENY is returned. Returns NULL if the policy policy is not specified for the given response.

Overrides ResponsePolicyInterface::check

File

core/modules/node/src/PageCache/DenyNodePreview.php, line 38

Class

DenyNodePreview
Cache policy for node preview page.

Namespace

Drupal\node\PageCache

Code

public function check(Response $response, Request $request) {
    if ($this->routeMatch
        ->getRouteName() === 'entity.node.preview') {
        return static::DENY;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.