Version 1
[yaffs-website] / web / core / modules / toolbar / src / PageCache / AllowToolbarPath.php
1 <?php
2
3 namespace Drupal\toolbar\PageCache;
4
5 use Drupal\Core\PageCache\RequestPolicyInterface;
6 use Symfony\Component\HttpFoundation\Request;
7
8 /**
9  * Cache policy for the toolbar page cache service.
10  *
11  * This policy allows caching of requests directed to /toolbar/subtrees/{hash}
12  * even for authenticated users.
13  */
14 class AllowToolbarPath implements RequestPolicyInterface {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function check(Request $request) {
20     // Note that this regular expression matches the end of pathinfo in order to
21     // support multilingual sites using path prefixes.
22     if (preg_match('#/toolbar/subtrees/[^/]+(/[^/]+)?$#', $request->getPathInfo())) {
23       return static::ALLOW;
24     }
25   }
26
27 }