AllowToolbarPath.php

Same filename in other branches
  1. 9 core/modules/toolbar/src/PageCache/AllowToolbarPath.php
  2. 10 core/modules/toolbar/src/PageCache/AllowToolbarPath.php
  3. 11.x core/modules/toolbar/src/PageCache/AllowToolbarPath.php

Namespace

Drupal\toolbar\PageCache

File

core/modules/toolbar/src/PageCache/AllowToolbarPath.php

View source
<?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;
        }
    }

}

Classes

Title Deprecated Summary
AllowToolbarPath Cache policy for the toolbar page cache service.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.