annotate core/modules/toolbar/src/PageCache/AllowToolbarPath.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\toolbar\PageCache;
Chris@0 4
Chris@0 5 use Drupal\Core\PageCache\RequestPolicyInterface;
Chris@0 6 use Symfony\Component\HttpFoundation\Request;
Chris@0 7
Chris@0 8 /**
Chris@0 9 * Cache policy for the toolbar page cache service.
Chris@0 10 *
Chris@0 11 * This policy allows caching of requests directed to /toolbar/subtrees/{hash}
Chris@0 12 * even for authenticated users.
Chris@0 13 */
Chris@0 14 class AllowToolbarPath implements RequestPolicyInterface {
Chris@0 15
Chris@0 16 /**
Chris@0 17 * {@inheritdoc}
Chris@0 18 */
Chris@0 19 public function check(Request $request) {
Chris@0 20 // Note that this regular expression matches the end of pathinfo in order to
Chris@0 21 // support multilingual sites using path prefixes.
Chris@0 22 if (preg_match('#/toolbar/subtrees/[^/]+(/[^/]+)?$#', $request->getPathInfo())) {
Chris@0 23 return static::ALLOW;
Chris@0 24 }
Chris@0 25 }
Chris@0 26
Chris@0 27 }