mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add chill_path_force_return_path
method to routing helper
Implemented a new Twig function `chill_path_force_return_path` to enforce a specific return path within the URL. Updated relevant template to utilize this new function for better control over URL routing and return path management. OP#787 https://champs-libres.openproject.com/work_packages/787
This commit is contained in:
parent
d7174cdb95
commit
989fdad561
@ -56,9 +56,32 @@ class ChillTwigRoutingHelper extends AbstractExtension
|
|||||||
new TwigFunction('chill_return_path_or', $this->getReturnPathOr(...), ['is_safe_callback' => $this->isUrlGenerationSafe(...)]),
|
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_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_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)
|
public function getLabelReturnPath($default)
|
||||||
{
|
{
|
||||||
$request = $this->requestStack->getCurrentRequest();
|
$request = $this->requestStack->getCurrentRequest();
|
||||||
|
@ -341,7 +341,7 @@
|
|||||||
{{ entityWorkflow|chill_entity_render_string }}
|
{{ entityWorkflow|chill_entity_render_string }}
|
||||||
<ul class="record_actions small slim">
|
<ul class="record_actions small slim">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ chill_path_add_return_path('chill_main_workflow_signature_metadata', {signature_id: signature.id}) }}" class="btn btn-misc">
|
<a href="{{ chill_path_force_return_path(path('chill_main_workflow_show', {id: entityWorkflow.id}), 'chill_main_workflow_signature_metadata', {signature_id: signature.id}) }}" class="btn btn-misc">
|
||||||
<i class="fa fa-pencil"></i>
|
<i class="fa fa-pencil"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user