2022-05-10 15:21:29 +02:00

55 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\ThirdPartyBundle\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('Third party', [
'route' => 'chill_thirdparty_admin_index',
])
->setAttribute('class', 'list-group-item-header')
->setExtras([
'order' => 3000,
'icons' => ['male'],
]);
$menu->addChild('Third party category', [
'route' => 'chill_crud_thirdparty_thirdparty-category_index',
])->setExtras(['order' => 3010]);
}
public static function getMenuIds(): array
{
return ['admin_section', 'admin_thirdparty'];
}
}