You are here

public function PreviewLinkCacheContext::getContext in Preview Link 8

Same name and namespace in other branches
  1. 2.x src/PreviewLinkCacheContext.php \Drupal\preview_link\PreviewLinkCacheContext::getContext()
  2. 2.0.x src/PreviewLinkCacheContext.php \Drupal\preview_link\PreviewLinkCacheContext::getContext()

Returns the string representation of the cache context.

A cache context service's name is used as a token (placeholder) cache key, and is then replaced with the string returned by this method.

Return value

string The string representation of the cache context.

Overrides CacheContextInterface::getContext

File

src/PreviewLinkCacheContext.php, line 41

Class

PreviewLinkCacheContext
Defines a class for a preview link cache context.

Namespace

Drupal\preview_link

Code

public function getContext() {
  return ($route = $this->routeMatch
    ->getRouteObject()) && $route
    ->getOption('_preview_link_route') ?: FALSE;
}