mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
add translations
This commit is contained in:
42
src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php
Normal file
42
src/Bundle/ChillDocGeneratorBundle/Menu/AdminMenuBuilder.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\DocGeneratorBundle\Menu;
|
||||
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
class AdminMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(TranslatorInterface $translator, Security $security)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
if ($this->security->isGranted('ROLE_ADMIN')) {
|
||||
if (in_array($menuId, ['admin_index', 'admin_section'])) {
|
||||
$menu->addChild($this->translator->trans('docgen.Document generation'), [
|
||||
'route' => 'chill_crud_docgen_template_index'
|
||||
])->setExtras([
|
||||
'order' => 350,
|
||||
'explain' => 'docgen.Manage templates and document generation'
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
{
|
||||
return ['admin_index', 'admin_section', ['docgen_admin']];
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user