59 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
/*
* 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.
*/
namespace Chill\MainBundle\Routing\MenuBuilder;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class AdminLanguageMenuBuilder implements LocalMenuBuilderInterface
{
/**
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{
$this->authorizationChecker = $authorizationChecker;
}
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
// all the entries below must have ROLE_ADMIN permissions
if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) {
return;
}
$menu->addChild('Languages and countries', [
'route' => 'chill_main_language_admin',
])
->setAttribute('class', 'list-group-item-header')
->setExtras([
'order' => 1200,
'icons' => ['globe-w'],
]);
$menu->addChild('Language list', [
'route' => 'chill_crud_main_language_index',
])->setExtras(['order' => 1210]);
$menu->addChild('Country list', [
'route' => 'chill_crud_main_country_index',
])->setExtras(['order' => 1220]);
}
public static function getMenuIds(): array
{
return ['admin_section', 'admin_language'];
}
}