You are here

public function ExcludePages::check in Advanced Page Expiration 8

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

src/PageCache/ExcludePages.php, line 42

Class

ExcludePages
Cache policy that denies caching if the page matches a list of exclusions.

Namespace

Drupal\ape\PageCache

Code

public function check(Response $response, Request $request) {

  /* @var \Drupal\system\Plugin\Condition\RequestPath $condition */
  $condition = $this->conditionManager
    ->createInstance('request_path');
  $condition
    ->setConfig('pages', $this->config
    ->get('exclusions'));
  if (!empty($this->config
    ->get('exclusions')) && $condition
    ->evaluate()) {
    return static::DENY;
  }
}