Commit 81658d5c authored by catch's avatar catch

Issue #2512132 by Wim Leers, effulgentsia, Fabianx: Make CSRF links cacheable

parent 5db18653
......@@ -24,6 +24,11 @@ services:
arguments: ['@request_stack']
tags:
- { name: cache.context }
cache_context.session:
class: Drupal\Core\Cache\Context\SessionCacheContext
arguments: ['@request_stack']
tags:
- { name: cache.context}
cache_context.request_format:
class: Drupal\Core\Cache\Context\RequestFormatCacheContext
arguments: ['@request_stack']
......
......@@ -504,22 +504,22 @@ public static function urlGenerator() {
* (optional) An associative array of parameter names and values.
* @param array $options
* (optional) An associative array of additional options.
* @param bool $collect_cacheability_metadata
* @param bool $collect_bubbleable_metadata
* (optional) Defaults to FALSE. When TRUE, both the generated URL and its
* associated cacheability metadata are returned.
* associated bubbleable metadata are returned.
*
* @return string|\Drupal\Core\GeneratedUrl
* A string containing a URL to the given path.
* When $collect_cacheability_metadata is TRUE, a GeneratedUrl object is
* returned, containing the generated URL plus cacheability metadata.
* When $collect_bubbleable_metadata is TRUE, a GeneratedUrl object is
* returned, containing the generated URL plus bubbleable metadata.
*
* @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute()
* @see \Drupal\Core\Url
* @see \Drupal\Core\Url::fromRoute()
* @see \Drupal\Core\Url::fromUri()
*/
public static function url($route_name, $route_parameters = array(), $options = array(), $collect_cacheability_metadata = FALSE) {
return static::getContainer()->get('url_generator')->generateFromRoute($route_name, $route_parameters, $options, $collect_cacheability_metadata);
public static function url($route_name, $route_parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
return static::getContainer()->get('url_generator')->generateFromRoute($route_name, $route_parameters, $options, $collect_bubbleable_metadata);
}
/**
......@@ -542,20 +542,20 @@ public static function linkGenerator() {
* The link text for the anchor tag.
* @param \Drupal\Core\Url $url
* The URL object used for the link.
* @param bool $collect_cacheability_metadata
* @param bool $collect_bubbleable_metadata
* (optional) Defaults to FALSE. When TRUE, both the generated URL and its
* associated cacheability metadata are returned.
* associated bubbleable metadata are returned.
*
* @return string|\Drupal\Core\GeneratedLink
* An HTML string containing a link to the given route and parameters.
* When $collect_cacheability_metadata is TRUE, a GeneratedLink object is
* returned, containing the generated link plus cacheability metadata.
* When $collect_bubbleable_metadata is TRUE, a GeneratedLink object is
* returned, containing the generated link plus bubbleable metadata.
*
* @see \Drupal\Core\Utility\LinkGeneratorInterface::generate()
* @see \Drupal\Core\Url
*/
public static function l($text, Url $url, $collect_cacheability_metadata = FALSE) {
return static::getContainer()->get('link_generator')->generate($text, $url, $collect_cacheability_metadata);
public static function l($text, Url $url, $collect_bubbleable_metadata = FALSE) {
return static::getContainer()->get('link_generator')->generate($text, $url, $collect_bubbleable_metadata);
}
/**
......
......@@ -7,7 +7,7 @@
namespace Drupal\Core\Access;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface;
use Symfony\Component\Routing\Route;
......@@ -36,7 +36,7 @@ function __construct(CsrfTokenGenerator $csrf_token) {
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL) {
public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
if ($route->hasRequirement('_csrf_token')) {
$path = ltrim($route->getPath(), '/');
// Replace the path parameters with values from the parameters array.
......@@ -45,13 +45,44 @@ public function processOutbound($route_name, Route $route, array &$parameters, C
}
// Adding this to the parameters means it will get merged into the query
// string when the route is compiled.
$parameters['token'] = $this->csrfToken->get($path);
if ($cacheable_metadata) {
// Tokens are per user and per session, so not cacheable.
// @todo Improve in https://www.drupal.org/node/2351015.
$cacheable_metadata->setCacheMaxAge(0);
if (!$bubbleable_metadata) {
$parameters['token'] = $this->csrfToken->get($path);
}
else {
// Generate a placeholder and a render array to replace it.
$placeholder = hash('sha1', $path);
$placeholder_render_array = [
'#lazy_builder' => ['route_processor_csrf:renderPlaceholderCsrfToken', [$path]],
];
// Instead of setting an actual CSRF token as the query string, we set
// the placeholder, which will be replaced at the very last moment. This
// ensures links with CSRF tokens don't break cacheability.
$parameters['token'] = $placeholder;
$bubbleable_metadata->addAttachments(['placeholders' => [$placeholder => $placeholder_render_array]]);
}
}
}
/**
* #lazy_builder callback; gets a CSRF token for the given path.
*
* @param string $path
* The path to get a CSRF token for.
*
* @return array
* A renderable array representing the CSRF token.
*/
public function renderPlaceholderCsrfToken($path) {
return [
'#markup' => $this->csrfToken->get($path),
// Tokens are per session.
'#cache' => [
'contexts' => [
'session',
],
],
];
}
}
<?php
/**
* @file
* Contains \Drupal\Core\Cache\Context\SessionCacheContext.
*/
namespace Drupal\Core\Cache\Context;
/**
* Defines the SessionCacheContext service, for "per session" caching.
*
* Cache context ID: 'session'.
*/
class SessionCacheContext extends RequestStackCacheContextBase {
/**
* {@inheritdoc}
*/
public static function getLabel() {
return t('Session');
}
/**
* {@inheritdoc}
*/
public function getContext() {
return $this->requestStack->getCurrentRequest()->getSession()->getId();
}
}
......@@ -7,7 +7,7 @@
namespace Drupal\Core;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Used to return generated links, along with associated cacheability metadata.
......@@ -15,7 +15,7 @@
* Note: not to be confused with \Drupal\Core\Link, which is for passing around
* ungenerated links (typically link text + route name + route parameters).
*/
class GeneratedLink extends CacheableMetadata {
class GeneratedLink extends BubbleableMetadata {
/**
* The HTML string value containing a link.
......
......@@ -7,15 +7,15 @@
namespace Drupal\Core;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Used to return generated URLs, along with associated cacheability metadata.
* Used to return generated URLs, along with associated bubbleable metadata.
*
* Note: not to be confused with \Drupal\Core\Url, which is for passing around
* ungenerated URLs (typically route name + route parameters).
*/
class GeneratedUrl extends CacheableMetadata {
class GeneratedUrl extends BubbleableMetadata {
/**
* The string value of the URL.
......
......@@ -122,17 +122,17 @@ public function setUrl(Url $url) {
/**
* Generates the HTML for this Link object.
*
* @param bool $collect_cacheability_metadata
* @param bool $collect_bubbleable_metadata
* (optional) Defaults to FALSE. When TRUE, both the generated link and its
* associated cacheability metadata are returned.
* associated bubbleable metadata are returned.
*
* @return string|\Drupal\Core\GeneratedLink
* The link HTML markup.
* When $collect_cacheability_metadata is TRUE, a GeneratedLink object is
* returned, containing the generated link plus cacheability metadata.
* When $collect_bubbleable_metadata is TRUE, a GeneratedLink object is
* returned, containing the generated link plus bubbleable metadata.
*/
public function toString($collect_cacheability_metadata = FALSE) {
return $this->getLinkGenerator()->generateFromLink($this, $collect_cacheability_metadata);
public function toString($collect_bubbleable_metadata = FALSE) {
return $this->getLinkGenerator()->generateFromLink($this, $collect_bubbleable_metadata);
}
}
......@@ -7,7 +7,7 @@
namespace Drupal\Core\PathProcessor;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -25,12 +25,12 @@ interface OutboundPathProcessorInterface {
* generateFromPath() method.
* @param \Symfony\Component\HttpFoundation\Request $request
* The HttpRequest object representing the current request.
* @param \Drupal\Core\Cache\CacheableMetadata $cacheable_metadata
* (optional) Object to collect path processors' cacheability.
* @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata
* (optional) Object to collect path processors' bubbleable metadata.
*
* @return
* The processed path.
*/
public function processOutbound($path, &$options = array(), Request $request = NULL, CacheableMetadata $cacheable_metadata = NULL);
public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL);
}
......@@ -7,8 +7,8 @@
namespace Drupal\Core\PathProcessor;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Path\AliasManagerInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -44,7 +44,7 @@ public function processInbound($path, Request $request) {
/**
* Implements Drupal\Core\PathProcessor\OutboundPathProcessorInterface::processOutbound().
*/
public function processOutbound($path, &$options = array(), Request $request = NULL, CacheableMetadata $cacheable_metadata = NULL) {
public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
if (empty($options['alias'])) {
$langcode = isset($options['language']) ? $options['language']->getId() : NULL;
$path = $this->aliasManager->getAliasByPath($path, $langcode);
......
......@@ -7,8 +7,8 @@
namespace Drupal\Core\PathProcessor;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -48,7 +48,7 @@ public function processInbound($path, Request $request) {
/**
* Implements Drupal\Core\PathProcessor\OutboundPathProcessorInterface::processOutbound().
*/
public function processOutbound($path, &$options = array(), Request $request = NULL, CacheableMetadata $cacheable_metadata = NULL) {
public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
// The special path '<front>' links to the default front page.
if ($path === '/<front>') {
$path = '/';
......
......@@ -7,7 +7,7 @@
namespace Drupal\Core\PathProcessor;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -108,10 +108,10 @@ public function addOutbound(OutboundPathProcessorInterface $processor, $priority
/**
* Implements Drupal\Core\PathProcessor\OutboundPathProcessorInterface::processOutbound().
*/
public function processOutbound($path, &$options = array(), Request $request = NULL, CacheableMetadata $cacheable_metadata = NULL) {
public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {
$processors = $this->getOutbound();
foreach ($processors as $processor) {
$path = $processor->processOutbound($path, $options, $request, $cacheable_metadata);
$path = $processor->processOutbound($path, $options, $request, $bubbleable_metadata);
}
return $path;
}
......
......@@ -73,6 +73,27 @@ public static function createFromRenderArray(array $build) {
return $meta;
}
/**
* Creates a bubbleable metadata object from a depended object.
*
* @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $object
* The object whose cacheability metadata to retrieve. If it implements
* CacheableDependencyInterface, its cacheability metadata will be used,
* otherwise, the passed in object must be assumed to be uncacheable, so
* max-age 0 is set.
*
* @return static
*/
public static function createFromObject($object) {
$meta = parent::createFromObject($object);
if ($object instanceof AttachmentsInterface) {
$meta->attachments = $object->getAttachments();
}
return $meta;
}
/**
* Merges two attachments arrays (which live under the '#attached' key).
*
......
......@@ -10,6 +10,7 @@
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\Html as HtmlUtility;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Url as CoreUrl;
/**
......@@ -83,7 +84,7 @@ public static function preRenderLink($element) {
$link_generator = \Drupal::service('link_generator');
$generated_link = $link_generator->generate($element['#title'], $element['#url']->setOptions($options), TRUE);
$element['#markup'] = $generated_link->getGeneratedLink();
$generated_link->merge(CacheableMetadata::createFromRenderArray($element))
$generated_link->merge(BubbleableMetadata::createFromRenderArray($element))
->applyTo($element);
}
return $element;
......
......@@ -7,7 +7,7 @@
namespace Drupal\Core\RouteProcessor;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\Routing\Route;
/**
......@@ -25,12 +25,12 @@ interface OutboundRouteProcessorInterface {
* @param array $parameters
* An array of parameters to be passed to the route compiler. Passed by
* reference.
* @param \Drupal\Core\Cache\CacheableMetadata $cacheable_metadata
* (optional) Object to collect route processors' cacheability.
* @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata
* (optional) Object to collect route processors' bubbleable metadata.
*
* @return
* The processed path.
*/
public function processOutbound($route_name, Route $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL);
public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL);
}
......@@ -8,6 +8,7 @@
namespace Drupal\Core\RouteProcessor;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\Routing\Route;
......@@ -36,7 +37,7 @@ public function __construct(RouteMatchInterface $route_match) {
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL) {
public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
if ($route_name === '<current>') {
if ($current_route = $this->routeMatch->getRouteObject()) {
$requirements = $current_route->getRequirements();
......@@ -52,8 +53,8 @@ public function processOutbound($route_name, Route $route, array &$parameters, C
$route->setOptions($current_route->getOptions());
$route->setDefaults($current_route->getDefaults());
$parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
if ($cacheable_metadata) {
$cacheable_metadata->addCacheContexts(['route']);
if ($bubbleable_metadata) {
$bubbleable_metadata->addCacheContexts(['route']);
}
}
else {
......
......@@ -7,7 +7,7 @@
namespace Drupal\Core\RouteProcessor;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\Routing\Route;
/**
......@@ -51,10 +51,10 @@ public function addOutbound(OutboundRouteProcessorInterface $processor, $priorit
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL) {
public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
$processors = $this->getOutbound();
foreach ($processors as $processor) {
$processor->processOutbound($route_name, $route, $parameters, $cacheable_metadata);
$processor->processOutbound($route_name, $route, $parameters, $bubbleable_metadata);
}
}
......
......@@ -7,7 +7,7 @@
namespace Drupal\Core\Routing;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
......@@ -51,7 +51,7 @@ protected function getRoute($name) {
/**
* {@inheritdoc}
*/
protected function processRoute($name, Route $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL) {
protected function processRoute($name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
}
/**
......@@ -76,7 +76,7 @@ public function getContext() {
/**
* Overrides Drupal\Core\Routing\UrlGenerator::processPath().
*/
protected function processPath($path, &$options = array(), CacheableMetadata $cacheable_metadata = NULL) {
protected function processPath($path, &$options = array(), BubbleableMetadata $bubbleable_metadata = NULL) {
return $path;
}
}
......@@ -7,8 +7,8 @@
namespace Drupal\Core\Routing;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\GeneratedUrl;
use Drupal\Core\Render\BubbleableMetadata;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RequestContext as SymfonyRequestContext;
use Symfony\Component\Routing\Route as SymfonyRoute;
......@@ -277,8 +277,8 @@ public function generate($name, $parameters = array(), $absolute = FALSE) {
/**
* {@inheritdoc}
*/
public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_cacheability_metadata = FALSE) {
$generated_url = $collect_cacheability_metadata ? new GeneratedUrl() : NULL;
public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) {
$generated_url = $collect_bubbleable_metadata ? new GeneratedUrl() : NULL;
$options += array('prefix' => '');
$route = $this->getRoute($name);
......@@ -321,7 +321,7 @@ public function generateFromRoute($name, $parameters = array(), $options = array
}
$url = $base_url . $path . $fragment;
return $collect_cacheability_metadata ? $generated_url->setGeneratedUrl($url) : $url;
return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($url) : $url;
}
$base_url = $this->context->getBaseUrl();
......@@ -330,11 +330,11 @@ public function generateFromRoute($name, $parameters = array(), $options = array
if (!$absolute || !$host = $this->context->getHost()) {
if ($route->getOption('_only_fragment')) {
return $collect_cacheability_metadata ? $generated_url->setGeneratedUrl($fragment) : $fragment;
return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($fragment) : $fragment;
}
$url = $base_url . $path . $fragment;
return $collect_cacheability_metadata ? $generated_url->setGeneratedUrl($url) : $url;
return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($url) : $url;
}
// Prepare an absolute URL by getting the correct scheme, host and port from
......@@ -355,19 +355,19 @@ public function generateFromRoute($name, $parameters = array(), $options = array
} elseif ('https' === $scheme && 443 != $this->context->getHttpsPort()) {
$port = ':' . $this->context->getHttpsPort();
}
if ($collect_cacheability_metadata) {
if ($collect_bubbleable_metadata) {
$generated_url->addCacheContexts(['url.site']);
}
$url = $scheme . '://' . $host . $port . $base_url . $path . $fragment;
return $collect_cacheability_metadata ? $generated_url->setGeneratedUrl($url) : $url;
return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($url) : $url;
}
/**
* {@inheritdoc}
*/
public function generateFromPath($path = NULL, $options = array(), $collect_cacheability_metadata = FALSE) {
$generated_url = $collect_cacheability_metadata ? new GeneratedUrl() : NULL;
public function generateFromPath($path = NULL, $options = array(), $collect_bubbleable_metadata = FALSE) {
$generated_url = $collect_bubbleable_metadata ? new GeneratedUrl() : NULL;
$request = $this->requestStack->getCurrentRequest();
$current_base_path = $request->getBasePath() . '/';
......@@ -432,7 +432,7 @@ public function generateFromPath($path = NULL, $options = array(), $collect_cach
}
// Reassemble.
$url = $path . $options['fragment'];
return $collect_cacheability_metadata ? $generated_url->setGeneratedUrl($url) : $url;
return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($url) : $url;
}
else {
$path = ltrim($this->processPath('/' . $path, $options, $generated_url), '/');
......@@ -463,20 +463,20 @@ public function generateFromPath($path = NULL, $options = array(), $collect_cach
$base = $options['absolute'] ? $options['base_url'] : $current_base_path;
$prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
if ($options['absolute'] && $collect_cacheability_metadata) {
if ($options['absolute'] && $collect_bubbleable_metadata) {
$generated_url->addCacheContexts(['url.site']);
}
$path = str_replace('%2F', '/', rawurlencode($prefix . $path));
$query = $options['query'] ? ('?' . UrlHelper::buildQuery($options['query'])) : '';
$url = $base . $options['script'] . $path . $query . $options['fragment'];
return $collect_cacheability_metadata ? $generated_url->setGeneratedUrl($url) : $url;
return $collect_bubbleable_metadata ? $generated_url->setGeneratedUrl($url) : $url;
}
/**
* Passes the path to a processor manager to allow alterations.
*/
protected function processPath($path, &$options = array(), CacheableMetadata $cacheable_metadata = NULL) {
protected function processPath($path, &$options = array(), BubbleableMetadata $bubbleable_metadata = NULL) {
// Router-based paths may have a querystring on them.
if ($query_pos = strpos($path, '?')) {
// We don't need to do a strict check here because position 0 would mean we
......@@ -488,7 +488,7 @@ protected function processPath($path, &$options = array(), CacheableMetadata $ca
$actual_path = $path;
$query_string = '';
}
$path = $this->pathProcessor->processOutbound($actual_path === '/' ? $actual_path : rtrim($actual_path, '/'), $options, $this->requestStack->getCurrentRequest(), $cacheable_metadata);
$path = $this->pathProcessor->processOutbound($actual_path === '/' ? $actual_path : rtrim($actual_path, '/'), $options, $this->requestStack->getCurrentRequest(), $bubbleable_metadata);
$path .= $query_string;
return $path;
}
......@@ -502,11 +502,11 @@ protected function processPath($path, &$options = array(), CacheableMetadata $ca
* The route object to process.
* @param array $parameters
* An array of parameters to be passed to the route compiler.
* @param \Drupal\Core\Cache\CacheableMetadata $cacheable_metadata
* (optional) Object to collect route processors' cacheability.
* @param \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata
* (optional) Object to collect route processors' bubbleable metadata.
*/
protected function processRoute($name, SymfonyRoute $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL) {
$this->routeProcessor->processOutbound($name, $route, $parameters, $cacheable_metadata);
protected function processRoute($name, SymfonyRoute $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
$this->routeProcessor->processOutbound($name, $route, $parameters, $bubbleable_metadata);
}
/**
......
......@@ -70,14 +70,14 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface {
* set if _url() is invoked by Drupal\Core\Entity\Entity::uri().
* - 'entity': The entity object (such as a node) for which the URL is being
* generated. Only set if _url() is invoked by Drupal\Core\Entity\Entity::uri().
* @param bool $collect_cacheability_metadata
* @param bool $collect_bubbleable_metadata
* (optional) Defaults to FALSE. When TRUE, both the generated URL and its
* associated cacheability metadata are returned.
* associated bubbleable metadata are returned.
*
* @return string|\Drupal\Core\GeneratedUrl
* A string containing a URL to the given path.
* When $collect_cacheability_metadata is TRUE, a GeneratedUrl object is
* returned, containing the generated URL plus cacheability metadata.
* When $collect_bubbleable_metadata is TRUE, a GeneratedUrl object is
* returned, containing the generated URL plus bubbleable metadata.
*
* @throws \Drupal\Core\Routing\GeneratorNotInitializedException.
*
......@@ -92,7 +92,7 @@ interface UrlGeneratorInterface extends VersatileGeneratorInterface {
* @see \Drupal\Core\Url
* @see \Drupal\Core\GeneratedUrl
*/
public function generateFromPath($path = NULL, $options = array(), $collect_cacheability_metadata = FALSE);
public function generateFromPath($path = NULL, $options = array(), $collect_bubbleable_metadata = FALSE);
/**
* Gets the internal path (system path) of a route.
......@@ -142,14 +142,14 @@ public function getPathFromRoute($name, $parameters = array());
* modify the base URL when a language dependent URL requires so.