Sylius version affected: 1.13.10
Issue also created here : Sylius/Sylius#17686
Description
Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration manage crud redirection after update.
According to the function :
public function getRedirectRoute($name)
{
$redirect = $this->parameters->get('redirect');
if (null === $redirect) {
return $this->getRouteName($name);
}
if (is_array($redirect)) {
if (!empty($redirect['referer'])) {
return 'referer';
}
return $redirect['route'];
}
return $redirect;
}
There is a possibility to configure custom ressource crud redirection called 'referer'.
And allow user to go back on the previous request url.
Actually, by default, the user is redirected to the show route, according to Sylius\Bundle\ResourceBundle\Controller\RedirectHandler file :
public function redirectToResource(RequestConfiguration $configuration, ResourceInterface $resource): Response
{
try {
return $this->redirectToRoute(
$configuration,
(string) $configuration->getRedirectRoute(ResourceActions::SHOW),
$configuration->getRedirectParameters($resource),
);
} catch ...
}
The expected behavior, after configuring my referer redirection in my route configuration is that the function getRedirectRoute return referer.
public function redirectToRoute(RequestConfiguration $configuration, string $route, array $parameters = []): Response
{
if ('referer' === $route) {
return $this->redirectToReferer($configuration);
}
....
But it's not working, because now Sylius rework the route name and add a prefix.
For exemple :
public function getRedirectRoute($name)
{
$redirect = $this->parameters->get('redirect');
dump($redirect);
The dump return 'app_admin_test_referer' instead of the configured value.
Steps to reproduce
Create a custom resource admin and add a referer redirection and in your routes.yaml add redirection: referer:
custom_resource_test_admin:
resource: |
alias: custom_resource.test
section: admin
redirect: referer
Possible Solution
Into Sylius\Bundle\ResourceBundle\Controller\RequestConfiguration change way to detect 'referer' value.
if (is_string($redirect) and str_ends_with($redirect, 'referer'))
Sylius version affected: 1.13.10
Issue also created here : Sylius/Sylius#17686
Description
Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationmanage crud redirection after update.According to the function :
There is a possibility to configure custom ressource crud redirection called 'referer'.
And allow user to go back on the previous request url.
Actually, by default, the user is redirected to the show route, according to
Sylius\Bundle\ResourceBundle\Controller\RedirectHandlerfile :The expected behavior, after configuring my referer redirection in my route configuration is that the function
getRedirectRoutereturnreferer.But it's not working, because now Sylius rework the route name and add a prefix.
For exemple :
The dump return 'app_admin_test_referer' instead of the configured value.
Steps to reproduce
Create a custom resource admin and add a referer redirection and in your
routes.yamladdredirection: referer:Possible Solution
Into
Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationchange way to detect 'referer' value.