class BakeryRequestPolicy in Bakery Single Sign-On System 8.2
A policy allowing delivery of cached pages when there is no session open.
Do not serve cached pages to authenticated users, or to anonymous users when CHOCOLATECHIPCOOKIE exist in the request header.
Hierarchy
- class \Drupal\bakery\PageCache\BakeryRequestPolicy implements RequestPolicyInterface
Expanded class hierarchy of BakeryRequestPolicy
1 string reference to 'BakeryRequestPolicy'
1 service uses BakeryRequestPolicy
File
- src/
PageCache/ BakeryRequestPolicy.php, line 14
Namespace
Drupal\bakery\PageCacheView source
class BakeryRequestPolicy implements RequestPolicyInterface {
/**
* {@inheritdoc}
*/
public function check(Request $request) {
if ($this
->pregArrayKeyExists('/^CHOCOLATECHIP/', $request->cookies
->all())) {
return self::DENY;
}
return NULL;
}
/**
* Check pattern key exist in array.
*
* @param string $pattern
* Regex pattern to match key.
* @param array $array
* Array from which key needs to be checked.
*
* @return int
* if found return positive number else -1
*/
private function pregArrayKeyExists($pattern, $array) {
$keys = array_keys($array);
return (int) preg_grep($pattern, $keys);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BakeryRequestPolicy:: |
public | function |
Determines whether delivery of a cached page should be attempted. Overrides RequestPolicyInterface:: |
|
BakeryRequestPolicy:: |
private | function | Check pattern key exist in array. | |
RequestPolicyInterface:: |
constant | Allow delivery of cached pages. | ||
RequestPolicyInterface:: |
constant | Deny delivery of cached pages. |