diff --git a/Controller/EventController.php b/Controller/EventController.php index 74fa339f2..986efc24d 100644 --- a/Controller/EventController.php +++ b/Controller/EventController.php @@ -224,4 +224,12 @@ class EventController extends Controller 'edit_form' => $editForm->createView(), )); } + + /** + * List events subscriptions for a person + * @param $person_id + */ + public function listByPersonAction($person_id) + { + } } diff --git a/DependencyInjection/ChillEventExtension.php b/DependencyInjection/ChillEventExtension.php index 1e0443899..1026b1e08 100644 --- a/DependencyInjection/ChillEventExtension.php +++ b/DependencyInjection/ChillEventExtension.php @@ -31,6 +31,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface $loader->load('authorization.yml'); $loader->load('forms.yml'); $loader->load('fixtures.yml'); + $loader->load('menu.yml'); } /* (non-PHPdoc) diff --git a/Menu/PersonMenuBuilder.php b/Menu/PersonMenuBuilder.php new file mode 100644 index 000000000..5ce5e8e65 --- /dev/null +++ b/Menu/PersonMenuBuilder.php @@ -0,0 +1,71 @@ +tokenStorage = $tokenStorage; + $this->translator = $translator; + $this->authorizationHelper = $authorizationHelper; + } + + + public function buildMenu($menuId, MenuItem $menu, array $parameters) + { + /* @var $person \Chill\PersonBundle\Entity\Person */ + $person = $parameters['person']; + + $user = $this->tokenStorage->getToken()->getUser(); + $roleSee = new Role(EventVoter::SEE); + + // ASK use authorizationHelper or authorizationChecker ?? + if ($this->authorizationHelper->userHasAccess($user, $person, $roleSee)) { + + $menu->addChild($this->translator->trans('Events participation'), [ + 'route' => 'chill_event__list_by_person', + 'routeParameters' => [ + 'person_id' => $person->getId() + ] + ]) + ->setExtras([ + 'order' => 500 + ]); + } + } + + public static function getMenuIds(): array + { + return [ 'person' ]; + } +} \ No newline at end of file diff --git a/Resources/config/routing/event.yml b/Resources/config/routing/event.yml index 256850e5c..1bdb59e62 100644 --- a/Resources/config/routing/event.yml +++ b/Resources/config/routing/event.yml @@ -35,3 +35,7 @@ chill_event__event_update: path: /{event_id}/update defaults: { _controller: "ChillEventBundle:Event:update" } methods: [POST, PUT] + +chill_event__list_by_person: + path: /{person_id}/list + defaults: { _controller: "ChillEventBundle:Event:listByPerson" } diff --git a/Resources/config/services/menu.yml b/Resources/config/services/menu.yml new file mode 100644 index 000000000..209d208a7 --- /dev/null +++ b/Resources/config/services/menu.yml @@ -0,0 +1,8 @@ +services: + Chill\EventBundle\Menu\PersonMenuBuilder: + arguments: + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' + $translator: '@Symfony\Component\Translation\TranslatorInterface' + tags: + - { name: 'chill.menu_builder' } \ No newline at end of file diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index 992b1c2e0..08a62287f 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -39,6 +39,7 @@ Participation Edit: Modifier une participation There are no participation to edit for this event: Il n'y a pas de participation pour cet événement The participations have been successfully updated.: Les participations ont été mises à jour. The participations were created: Les participations ont été créées +Events participation: Participation aux événements #search Event search: Recherche d'événements