+ /**
+ * Returns the cache ID for the route collection cache.
+ *
+ * @param \Symfony\Component\HttpFoundation\Request $request
+ * The request object.
+ *
+ * @return string
+ * The cache ID.
+ */
+ protected function getRouteCollectionCacheId(Request $request) {
+ // Include the current language code in the cache identifier as
+ // the language information can be elsewhere than in the path, for example
+ // based on the domain.
+ $language_part = $this->getCurrentLanguageCacheIdPart();
+ return 'route:' . $language_part . ':' . $request->getPathInfo() . ':' . $request->getQueryString();
+ }
+
+ /**
+ * Returns the language identifier for the route collection cache.
+ *
+ * @return string
+ * The language identifier.
+ */
+ protected function getCurrentLanguageCacheIdPart() {
+ // This must be in sync with the language logic in
+ // \Drupal\Core\PathProcessor\PathProcessorAlias::processInbound() and
+ // \Drupal\Core\Path\AliasManager::getPathByAlias().
+ // @todo Update this if necessary in https://www.drupal.org/node/1125428.
+ return $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();
+ }
+