sf4, fix section menu translations and add missing translations

This commit is contained in:
Tchama 2020-07-27 19:43:43 +02:00
parent 8d4d8f3a0d
commit 5245d9971e
3 changed files with 30 additions and 6 deletions

View File

@ -1,4 +1,5 @@
<?php
/*
* Copyright (C) 2018 Champs-Libres <info@champs-libres.coop>
*
@ -15,36 +16,54 @@
* 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\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Translation\TranslatorInterface;
/**
*
* Class SectionMenuBuilder
*
* @package Chill\PersonBundle\Menu
* @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
* @param TranslatorInterface $translator
*/
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)
{
if ($this->authorizationChecker->isGranted(PersonVoter::CREATE)) {
$menu->addChild('Add a person', [
$menu->addChild($this->translator->trans('Add a person'), [
'route' => 'chill_person_new'
])
->setExtras([
@ -53,7 +72,10 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
]);
}
}
/**
* @return array
*/
public static function getMenuIds(): array
{
return [ 'section' ];

View File

@ -2,6 +2,7 @@ services:
Chill\PersonBundle\Menu\SectionMenuBuilder:
arguments:
$authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'
$translator: '@Symfony\Component\Translation\TranslatorInterface'
tags:
- { name: 'chill.menu_builder' }

View File

@ -152,6 +152,7 @@ Back to the person details: Retour aux détails de la personne
Timeline: Historique
Closing the accompanying period: Fermeture de la période d'accompagnement
Opening the accompanying period: Ouverture d'une période d'accompagnement
'Timeline for %name%': 'Historique de %name%'
#roles
CHILL_PERSON_SEE: Voir les personnes