Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PathParentCacheContext.php

function PathParentCacheContext::getContext

Overrides CacheContextInterface::getContext

File

core/lib/Drupal/Core/Cache/Context/PathParentCacheContext.php, line 27

Class

PathParentCacheContext
Defines a cache context service for path parents.

Namespace

Drupal\Core\Cache\Context

Code

public function getContext() {
    $request = $this->requestStack
        ->getCurrentRequest();
    $path_elements = explode('/', trim($request->getPathInfo(), '/'));
    array_pop($path_elements);
    return implode('/', $path_elements);
}
RSS feed
Powered by Drupal