Mercurial > hg > isophonics-drupal-site
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/toolbar/src/PageCache/AllowToolbarPath.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,27 @@ +<?php + +namespace Drupal\toolbar\PageCache; + +use Drupal\Core\PageCache\RequestPolicyInterface; +use Symfony\Component\HttpFoundation\Request; + +/** + * Cache policy for the toolbar page cache service. + * + * This policy allows caching of requests directed to /toolbar/subtrees/{hash} + * even for authenticated users. + */ +class AllowToolbarPath implements RequestPolicyInterface { + + /** + * {@inheritdoc} + */ + public function check(Request $request) { + // Note that this regular expression matches the end of pathinfo in order to + // support multilingual sites using path prefixes. + if (preg_match('#/toolbar/subtrees/[^/]+(/[^/]+)?$#', $request->getPathInfo())) { + return static::ALLOW; + } + } + +}