diff --git a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php index 16aea6cca..dea2099e1 100644 --- a/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php +++ b/src/Bundle/ChillCalendarBundle/Controller/CalendarController.php @@ -18,6 +18,7 @@ use Chill\CalendarBundle\Repository\CalendarACLAwareRepositoryInterface; use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Pagination\PaginatorFactory; +use Chill\MainBundle\Repository\UserRepositoryInterface; use Chill\MainBundle\Templating\Listing\FilterOrderHelper; use Chill\MainBundle\Templating\Listing\FilterOrderHelperFactoryInterface; use Chill\PersonBundle\Entity\AccompanyingPeriod; @@ -62,6 +63,8 @@ class CalendarController extends AbstractController private SerializerInterface $serializer; + private UserRepositoryInterface $userRepository; + public function __construct( CalendarACLAwareRepositoryInterface $calendarACLAwareRepository, DocGeneratorTemplateRepository $docGeneratorTemplateRepository, @@ -71,7 +74,8 @@ class CalendarController extends AbstractController RemoteCalendarConnectorInterface $remoteCalendarConnector, SerializerInterface $serializer, PersonRepository $personRepository, - AccompanyingPeriodRepository $accompanyingPeriodRepository + AccompanyingPeriodRepository $accompanyingPeriodRepository, + UserRepositoryInterface $userRepository ) { $this->calendarACLAwareRepository = $calendarACLAwareRepository; $this->docGeneratorTemplateRepository = $docGeneratorTemplateRepository; @@ -82,6 +86,7 @@ class CalendarController extends AbstractController $this->serializer = $serializer; $this->personRepository = $personRepository; $this->accompanyingPeriodRepository = $accompanyingPeriodRepository; + $this->userRepository = $userRepository; } /** @@ -145,7 +150,6 @@ class CalendarController extends AbstractController return $this->remoteCalendarConnector->getMakeReadyResponse($request->getUri()); } - $view = null; $em = $this->getDoctrine()->getManager(); [$person, $accompanyingPeriod] = [$entity->getPerson(), $entity->getAccompanyingPeriod()]; @@ -161,8 +165,11 @@ class CalendarController extends AbstractController } $form = $this->createForm(CalendarType::class, $entity) - ->add('save', SubmitType::class) - ->add('save_and_create_doc', SubmitType::class); + ->add('save', SubmitType::class); + + if (0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class)) { + $form->add('save_and_create_doc', SubmitType::class); + } $form->handleRequest($request); @@ -310,8 +317,11 @@ class CalendarController extends AbstractController } $form = $this->createForm(CalendarType::class, $entity) - ->add('save', SubmitType::class) - ->add('save_and_create_doc', SubmitType::class); + ->add('save', SubmitType::class); + + if (0 < $this->docGeneratorTemplateRepository->countByEntity(Calendar::class)) { + $form->add('save_and_create_doc', SubmitType::class); + } $form->handleRequest($request); diff --git a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig index fce022ac4..7d72922d1 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig +++ b/src/Bundle/ChillCalendarBundle/Resources/views/Calendar/edit.html.twig @@ -77,9 +77,11 @@ {{ 'Cancel'|trans|chill_return_path_label }} -