Add list of activities in AccompanyingCourse Menu

This commit is contained in:
Jean-Francois Monfort 2021-05-20 17:08:47 +02:00
parent 8fe00b4c2b
commit 2bae684df9
3 changed files with 21 additions and 6 deletions

View File

@ -311,6 +311,10 @@ class ActivityController extends AbstractController
$this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event); $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
*/ */
if ($view === null) {
throw $this->createNotFoundException('Template not found');
}
return $this->render($view, array( return $this->render($view, array(
'entity' => $entity, 'entity' => $entity,
'edit_form' => $form->createView(), 'edit_form' => $form->createView(),
@ -379,6 +383,10 @@ class ActivityController extends AbstractController
} }
} }
if ($view === null) {
throw $this->createNotFoundException('Template not found');
}
return $this->render($view, array( return $this->render($view, array(
'activity' => $activity, 'activity' => $activity,
'delete_form' => $form->createView(), 'delete_form' => $form->createView(),

View File

@ -2,16 +2,12 @@
namespace Chill\ActivityBundle\Menu; namespace Chill\ActivityBundle\Menu;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface; use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Knp\Menu\MenuItem; use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
{ {
protected TokenStorageInterface $tokenStorage; protected TokenStorageInterface $tokenStorage;
@ -38,11 +34,21 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
{ {
$period = $parameters['accompanyingCourse']; $period = $parameters['accompanyingCourse'];
$menu->addChild($this->translator->trans('List of activities'), [
'route' => 'chill_activity_activity_list',
'routeParameters' => [
'accompanying_period_id' => $period->getId(),
]])
->setExtras(['order' => 40]);
$menu->addChild($this->translator->trans('Add a new activity'), [ $menu->addChild($this->translator->trans('Add a new activity'), [
'route' => 'chill_activity_activity_select_type', 'route' => 'chill_activity_activity_select_type',
'routeParameters' => [ 'routeParameters' => [
'accompanying_period_id' => $period->getId() 'accompanying_period_id' => $period->getId(),
]]) ]])
->setExtras(['order' => 40]); ->setExtras(['order' => 41]);
} }
} }

View File

@ -12,5 +12,6 @@ services:
$tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface'
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
$translator: '@Symfony\Contracts\Translation\TranslatorInterface' $translator: '@Symfony\Contracts\Translation\TranslatorInterface'
$entityManager: '@Doctrine\ORM\EntityManagerInterface'
tags: tags:
- { name: 'chill.menu_builder' } - { name: 'chill.menu_builder' }