diff --git a/src/Bundle/ChillMainBundle/Routing/ChillUrlGenerator.php b/src/Bundle/ChillMainBundle/Routing/ChillUrlGenerator.php new file mode 100644 index 000000000..eaecee628 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Routing/ChillUrlGenerator.php @@ -0,0 +1,43 @@ +urlGenerator->generate($name, $parameters, $referenceType); + } + + public function generateWithReturnPath(string $name, array $parameters = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string + { + $uri = $this->requestStack->getCurrentRequest()->getRequestUri(); + + return $this->urlGenerator->generate($name, [$parameters, 'returnPath' => $uri], $referenceType); + } + + public function returnPathOr(string $name, array $parameters = [], int $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH): string + { + $request = $this->requestStack->getCurrentRequest(); + + if ($request->query->has('returnPath')) { + return $request->query->get('returnPath'); + } + + return $this->urlGenerator->generate($name, $parameters, $referenceType); + } +} diff --git a/src/Bundle/ChillMainBundle/Routing/ChillUrlGeneratorInterface.php b/src/Bundle/ChillMainBundle/Routing/ChillUrlGeneratorInterface.php new file mode 100644 index 000000000..5c00fa665 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Routing/ChillUrlGeneratorInterface.php @@ -0,0 +1,35 @@ +