mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fixed: [calendar] add a return path to calendar doc
See https://gitlab.com/Chill-Projet/chill-bundles/-/issues/23
This commit is contained in:
parent
788b1e9eeb
commit
9b32ce53c8
@ -16,6 +16,7 @@ use Chill\CalendarBundle\Security\Voter\CalendarVoter;
|
||||
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
@ -47,7 +48,7 @@ class CalendarDocController
|
||||
/**
|
||||
* @Route("/{_locale}/calendar/docgen/pick/{id}", name="chill_calendar_calendardoc_pick_template")
|
||||
*/
|
||||
public function pickTemplate(Calendar $calendar): Response
|
||||
public function pickTemplate(Calendar $calendar, Request $request): Response
|
||||
{
|
||||
if (!$this->security->isGranted(CalendarVoter::SEE, $calendar)) {
|
||||
throw new AccessDeniedException('Not authorized to see this calendar');
|
||||
@ -60,14 +61,21 @@ class CalendarDocController
|
||||
if (1 === $number) {
|
||||
$templates = $this->docGeneratorTemplateRepository->findByEntity(Calendar::class);
|
||||
|
||||
if ($request->query->has('returnPath')) {
|
||||
$returnPathParam = ['returnPath' => $request->query->get('returnPath')];
|
||||
}
|
||||
|
||||
return new RedirectResponse(
|
||||
$this->urlGenerator->generate(
|
||||
'chill_docgenerator_generate_from_template',
|
||||
[
|
||||
'template' => $templates[0]->getId(),
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $calendar->getId(),
|
||||
]
|
||||
array_merge(
|
||||
$returnPathParam ?? [],
|
||||
[
|
||||
'template' => $templates[0]->getId(),
|
||||
'entityClassName' => Calendar::class,
|
||||
'entityId' => $calendar->getId(),
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user