mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 22:34:24 +00:00
add item 'events participation' in person menu
This commit is contained in:
parent
d18f3dd3dd
commit
d89e440784
@ -224,4 +224,12 @@ class EventController extends Controller
|
|||||||
'edit_form' => $editForm->createView(),
|
'edit_form' => $editForm->createView(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List events subscriptions for a person
|
||||||
|
* @param $person_id
|
||||||
|
*/
|
||||||
|
public function listByPersonAction($person_id)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface
|
|||||||
$loader->load('authorization.yml');
|
$loader->load('authorization.yml');
|
||||||
$loader->load('forms.yml');
|
$loader->load('forms.yml');
|
||||||
$loader->load('fixtures.yml');
|
$loader->load('fixtures.yml');
|
||||||
|
$loader->load('menu.yml');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-PHPdoc)
|
/* (non-PHPdoc)
|
||||||
|
71
Menu/PersonMenuBuilder.php
Normal file
71
Menu/PersonMenuBuilder.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\EventBundle\Menu;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||||
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
|
use Knp\Menu\MenuItem;
|
||||||
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||||
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
|
use Chill\EventBundle\Security\Authorization\EventVoter;
|
||||||
|
|
||||||
|
class PersonMenuBuilder implements LocalMenuBuilderInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TokenStorageInterface
|
||||||
|
*/
|
||||||
|
protected $tokenStorage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TranslatorInterface
|
||||||
|
*/
|
||||||
|
protected $translator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var AuthorizationHelper
|
||||||
|
*/
|
||||||
|
protected $authorizationHelper;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
AuthorizationHelper $authorizationHelper,
|
||||||
|
TokenStorageInterface $tokenStorage,
|
||||||
|
TranslatorInterface $translator
|
||||||
|
) {
|
||||||
|
$this->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' ];
|
||||||
|
}
|
||||||
|
}
|
@ -35,3 +35,7 @@ chill_event__event_update:
|
|||||||
path: /{event_id}/update
|
path: /{event_id}/update
|
||||||
defaults: { _controller: "ChillEventBundle:Event:update" }
|
defaults: { _controller: "ChillEventBundle:Event:update" }
|
||||||
methods: [POST, PUT]
|
methods: [POST, PUT]
|
||||||
|
|
||||||
|
chill_event__list_by_person:
|
||||||
|
path: /{person_id}/list
|
||||||
|
defaults: { _controller: "ChillEventBundle:Event:listByPerson" }
|
||||||
|
8
Resources/config/services/menu.yml
Normal file
8
Resources/config/services/menu.yml
Normal file
@ -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' }
|
@ -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
|
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 have been successfully updated.: Les participations ont été mises à jour.
|
||||||
The participations were created: Les participations ont été créées
|
The participations were created: Les participations ont été créées
|
||||||
|
Events participation: Participation aux événements
|
||||||
|
|
||||||
#search
|
#search
|
||||||
Event search: Recherche d'événements
|
Event search: Recherche d'événements
|
||||||
|
Loading…
x
Reference in New Issue
Block a user