sf4, fix section menu translations and add missing translations

This commit is contained in:
2020-07-27 19:43:43 +02:00
parent 35640929f9
commit 930ab84a58
3 changed files with 30 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
<?php
/*
* Copyright (C) 2018 Champs Libres Cooperative <info@champs-libres.coop>
*
@@ -15,34 +16,52 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\MainBundle\Routing\MenuBuilder;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Chill\MainBundle\Security\Authorization\ChillExportVoter;
use Symfony\Component\Translation\TranslatorInterface;
/**
*
* Class SectionMenuBuilder
*
* @package Chill\MainBundle\Routing\MenuBuilder
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class SectionMenuBuilder implements LocalMenuBuilderInterface
{
/**
*
* @var AuthorizationCheckerInterface
*/
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
/**
* @var TranslatorInterface
*/
protected $translator;
/**
* SectionMenuBuilder constructor.
*
* @param AuthorizationCheckerInterface $authorizationChecker
*/
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator)
{
$this->authorizationChecker = $authorizationChecker;
$this->translator = $translator;
}
/**
* @param $menuId
* @param MenuItem $menu
* @param array $parameters
*/
public function buildMenu($menuId, MenuItem $menu, array $parameters)
{
$menu->addChild('Homepage', [
$menu->addChild($this->translator->trans('Homepage'), [
'route' => 'chill_main_homepage'
])
->setExtras([
@@ -51,7 +70,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
]);
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
$menu->addChild('Export Menu', [
$menu->addChild($this->translator->trans('Export Menu'), [
'route' => 'chill_main_export_index'
])
->setExtras([
@@ -60,7 +79,10 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
]);
}
}
/**
* @return array
*/
public static function getMenuIds(): array
{
return [ 'section' ];