[event] refactor admin for event bundle

This commit is contained in:
nobohan
2022-07-06 13:36:20 +02:00
parent 389f014d36
commit 36e35f2e8f
19 changed files with 118 additions and 89 deletions

View File

@@ -0,0 +1,61 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\EventBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class AdminMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{
$this->authorizationChecker = $authorizationChecker;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
return;
}
$menu->addChild('Events', [
'route' => 'chill_event_admin_index',
])
->setAttribute('class', 'list-group-item-header')
->setExtras([
'order' => 6500
]);
$menu->addChild('Event type', [
'route' => 'chill_eventtype_admin',
])->setExtras(['order' => 6510]);
$menu->addChild('Event status', [
'route' => 'chill_event_admin_status',
])->setExtras(['order' => 6520]);
$menu->addChild('Role', [
'route' => 'chill_event_admin_role',
])->setExtras(['order' => 6530]);
}
public static function getMenuIds(): array
{
return ['admin_section', 'admin_event'];
}
}