You are here

public function DenyCas::check in CAS 8

Same name and namespace in other branches
  1. 2.x src/PageCache/DenyCas.php \Drupal\cas\PageCache\DenyCas::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

src/PageCache/DenyCas.php, line 50

Class

DenyCas
Ensures pages configured with gateway authentication are not cached.

Namespace

Drupal\cas\PageCache

Code

public function check(Response $response, Request $request) {
  $config = $this->configFactory
    ->get('cas.settings');
  if ($config
    ->get('gateway.check_frequency') !== CasHelper::CHECK_NEVER) {

    // User can indicate specific paths to enable (or disable) gateway mode.
    $condition = $this->conditionManager
      ->createInstance('request_path');
    $condition
      ->setConfiguration($config
      ->get('gateway.paths'));
    if ($this->conditionManager
      ->execute($condition)) {
      return static::DENY;
    }
  }
  return NULL;
}