function CommandLineOrUnsafeMethod::check

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod::check()
  2. 8.9.x core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod::check()
  3. 10 core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php \Drupal\Core\PageCache\RequestPolicy\CommandLineOrUnsafeMethod::check()

Overrides RequestPolicyInterface::check

File

core/lib/Drupal/Core/PageCache/RequestPolicy/CommandLineOrUnsafeMethod.php, line 20

Class

CommandLineOrUnsafeMethod
Reject when running from the command line or when HTTP method is not safe.

Namespace

Drupal\Core\PageCache\RequestPolicy

Code

public function check(Request $request) {
    if ($this->isCli() || !$request->isMethodCacheable()) {
        return static::DENY;
    }
}

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