25 lines
502 B
Twig
25 lines
502 B
Twig
<?php
|
|
|
|
namespace Drupal\{{ machine_name }}\PageCache;
|
|
|
|
use Drupal\Core\PageCache\RequestPolicyInterface;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
/**
|
|
* A policy allowing to bypass cache for requests with 'no-cache' parameter.
|
|
*
|
|
* Example: https://example.com/node?no-cache.
|
|
*/
|
|
class {{ class }} implements RequestPolicyInterface {
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function check(Request $request) {
|
|
if (!is_null($request->get('no-cache'))) {
|
|
return self::DENY;
|
|
}
|
|
}
|
|
|
|
}
|