diff --git a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php index 5f67ccfe2..9e06eaee8 100644 --- a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php +++ b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php @@ -56,9 +56,32 @@ class ChillTwigRoutingHelper extends AbstractExtension new TwigFunction('chill_return_path_or', $this->getReturnPathOr(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]), new TwigFunction('chill_path_add_return_path', $this->getPathAddReturnPath(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]), new TwigFunction('chill_path_forward_return_path', $this->getPathForwardReturnPath(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]), + new TwigFunction('chill_path_force_return_path', $this->getPathForceReturnPath(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]), ]; } + /** + * Build a URL with a forced returnPath parameter. + * + * @param string $forcePath the forced path to return to + * @param string $name the name of the route + * @param array $parameters additional parameters for the URL + * @param bool $relative whether the URL should be relative + * @param string|null $label optional label for the return path + * + * @return string the generated URL + */ + public function getPathForceReturnPath(string $forcePath, string $name, array $parameters = [], $relative = false, $label = null): string + { + $params = [...$parameters, 'returnPath' => $forcePath]; + + if (null !== $label) { + $params['returnPathLabel'] = $label; + } + + return $this->originalExtension->getPath($name, $params, $relative); + } + public function getLabelReturnPath($default) { $request = $this->requestStack->getCurrentRequest(); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig index 7c75bc712..3c912ae58 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_with_period.html.twig @@ -341,7 +341,7 @@ {{ entityWorkflow|chill_entity_render_string }}