Skip to content
Snippets Groups Projects
Commit 1659e206 authored by Bohdan Mykhalchuk's avatar Bohdan Mykhalchuk Committed by Thomas Speer
Browse files

Issue #3415146 by spuky, rollins, ian-dev, Greg Boggs, david.houlder,...

Issue #3415146 by spuky, rollins, ian-dev, Greg Boggs, david.houlder, solideogloria: UnexpectedValueException (no corresponding route in Drupal\Core\Url->getRouteName()) after updating v2.0.3 to v2.0.4
parent d2b80a24
No related branches found
No related tags found
No related merge requests found
......@@ -70,15 +70,20 @@ class TitleResolver extends ControllerTitleResolver {
*/
public function getTitle(Request $request, Route $route) {
$url = Url::fromUri("internal:" . $request->getRequestUri());
$route_parts = explode(".", $url->getRouteName());
$entity = NULL;
$params = $url->getRouteParameters();
if (!empty($route_parts[0]) && $route_parts[0] === 'entity' && !empty($route_parts[2]) && $route_parts[2] === 'canonical') {
$entity_type = $route_parts[1];
if (isset($params[$entity_type])) {
$entity = $this->entityTypeManager->getStorage($entity_type)->load($params[$entity_type]);
try {
$route_parts = explode(".", $url->getRouteName());
$params = $url->getRouteParameters();
if ($route_parts[0] === 'entity' && $route_parts[2] === 'canonical') {
$entity_type = $route_parts[1];
if (isset($params[$entity_type])) {
$entity = $this->entityTypeManager->getStorage($entity_type)->load($params[$entity_type]);
}
}
}
catch (\UnexpectedValueException $e) {
// Do nothing for now.
}
if ($entity !== NULL) {
$current_langcode = $this->languageManager->getCurrentLanguage()->getId();
if ($entity instanceof TranslatableInterface && $entity->hasTranslation($current_langcode)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment