fix: properly forward return urls where missing
This commit is contained in:
@@ -32,6 +32,7 @@ class AppExtension extends AbstractExtension
|
||||
new TwigFunction('icon', [AppRuntime::class, 'renderIcon'], ['needs_environment' => true, 'is_safe' => ['html']]),
|
||||
new TwigFunction('is_current_route', [AppRuntime::class, 'isCurrentRoute']),
|
||||
new TwigFunction('return_url', [AppRuntime::class, 'getEncodedReturnUrl']),
|
||||
new TwigFunction('forwarded_return_url', [AppRuntime::class, 'getForwardedReturnUrl']),
|
||||
new TwigFunction('qa_attribute', [AppRuntime::class, 'renderQaAttribute'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('has_pickup', [AppRuntime::class, 'hasPickup']),
|
||||
];
|
||||
|
||||
@@ -192,6 +192,21 @@ class AppRuntime implements RuntimeExtensionInterface
|
||||
return rawurlencode($masterRequest->getRequestUri());
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes the return url of the current page on to the next one.
|
||||
*
|
||||
* Used by links that lead deeper into a detail view or trigger an action on it:
|
||||
* they have to keep pointing back at where the user originally came from instead
|
||||
* of at the page they sit on. Null when there is nothing to pass on, so that the
|
||||
* url generator drops the parameter rather than emitting an empty one.
|
||||
*/
|
||||
public function getForwardedReturnUrl(): ?string
|
||||
{
|
||||
$returnUrl = $this->requestStack->getMainRequest()?->query->get('r');
|
||||
|
||||
return is_string($returnUrl) && '' !== $returnUrl ? $returnUrl : null;
|
||||
}
|
||||
|
||||
public function renderQaAttribute(string $label, ?string $value = null): string
|
||||
{
|
||||
if ('test' !== $this->environment) {
|
||||
|
||||
Reference in New Issue
Block a user