mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?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\ActivityBundle\Menu;
|
|
|
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
use Knp\Menu\MenuItem;
|
|
use Symfony\Component\Security\Core\Security;
|
|
|
|
final class AdminMenuBuilder implements LocalMenuBuilderInterface
|
|
{
|
|
private Security $security;
|
|
|
|
public function __construct(Security $security)
|
|
{
|
|
$this->security = $security;
|
|
}
|
|
|
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
{
|
|
if (!$this->security->isGranted('ROLE_ADMIN')) {
|
|
return;
|
|
}
|
|
|
|
if (in_array($menuId, ['admin_index', 'admin_section'])) {
|
|
$menu->addChild('Activities', [
|
|
'route' => 'chill_admin_activity_index',
|
|
])
|
|
->setExtras([
|
|
'order' => 2000,
|
|
'explain' => 'Activity configuration',
|
|
]);
|
|
} else {
|
|
$menu
|
|
->addChild('Activities', [
|
|
'route' => 'chill_admin_activity_index',
|
|
])
|
|
->setExtras([
|
|
'order' => '60',
|
|
]);
|
|
}
|
|
}
|
|
|
|
public static function getMenuIds(): array
|
|
{
|
|
return ['admin_index', 'admin_section', 'admin_activity'];
|
|
}
|
|
}
|