Fix failing test

This commit is contained in:
Ivo Valchev
2020-04-23 15:54:18 +02:00
parent 100117331e
commit b7cf9f6790
2 changed files with 8 additions and 13 deletions
+8 -7
View File
@@ -197,18 +197,19 @@ class Canonical
return $routes->first();
}
// If requested locale is default, get the first route which is not named *_locale
if (array_key_exists('_locale', $params) && $params['_locale'] === $this->defaultLocale) {
unset($params['_locale']);
// If no locale or locale is not default, get the first route which is named *_locale
if (array_key_exists('_locale', $params) && $params['_locale'] !== $this->defaultLocale) {
return $routes->filter(function (string $name) {
return ! fnmatch('*locale', $name);
return fnmatch('*locale', $name);
})->first();
}
// Otherwise, get the first route that is *_locale
// Unset _locale so that it is not passed as query param to url.
unset($params['_locale']);
// Otherwise, get the first route that is not *_locale
return $routes->filter(function (string $name) {
return fnmatch('*locale', $name);
return ! fnmatch('*locale', $name);
})->first();
}
}
@@ -52,12 +52,6 @@ class DetailController extends TwigAwareController implements FrontendZoneInterf
$record = $this->contentRepository->findOneBySlug($slugOrId, $contentType);
}
// Update the canonical, with the correct path
$this->canonical->setPath(null, [
'contentTypeSlug' => $record ? $record->getContentTypeSingularSlug() : null,
'slugOrId' => $record ? $record->getSlug() : null,
]);
return $this->renderSingle($record, $requirePublished);
}