mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
options added to create person or parcours and to access global history
This commit is contained in:
parent
ff5aeaae17
commit
bdb07a3a05
@ -114,6 +114,11 @@ class ChillMainExtension extends Extension implements
|
||||
$config['available_countries']
|
||||
);
|
||||
|
||||
$container->setParameter(
|
||||
'chill_main.access_global_history',
|
||||
$config['access_global_history']
|
||||
);
|
||||
|
||||
$container->setParameter(
|
||||
'chill_main.routing.resources',
|
||||
$config['routing']['resources']
|
||||
|
@ -113,6 +113,9 @@ class Configuration implements ConfigurationInterface
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->booleanNode('access_global_history')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->arrayNode('redis')
|
||||
->children()
|
||||
->scalarNode('host')
|
||||
|
@ -14,6 +14,7 @@ namespace Chill\MainBundle\Routing\MenuBuilder;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\MainBundle\Security\Authorization\ChillExportVoter;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
@ -22,23 +23,20 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
*/
|
||||
class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var AuthorizationCheckerInterface
|
||||
*/
|
||||
protected $authorizationChecker;
|
||||
protected AuthorizationCheckerInterface $authorizationChecker;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
protected ParameterBagInterface $parameterBag;
|
||||
|
||||
/**
|
||||
* SectionMenuBuilder constructor.
|
||||
*/
|
||||
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator)
|
||||
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag)
|
||||
{
|
||||
$this->authorizationChecker = $authorizationChecker;
|
||||
$this->translator = $translator;
|
||||
$this->parameterBag = $parameterBag;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,14 +52,16 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
'order' => 0,
|
||||
]);
|
||||
|
||||
$menu->addChild($this->translator->trans('Global timeline'), [
|
||||
'route' => 'chill_center_timeline',
|
||||
])
|
||||
->setExtras(
|
||||
[
|
||||
'order' => 10,
|
||||
]
|
||||
);
|
||||
if ($this->parameterBag->get('chill_main.access_global_history')) {
|
||||
$menu->addChild($this->translator->trans('Global timeline'), [
|
||||
'route' => 'chill_center_timeline',
|
||||
])
|
||||
->setExtras(
|
||||
[
|
||||
'order' => 10,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->authorizationChecker->isGranted(ChillExportVoter::EXPORT)) {
|
||||
$menu->addChild($this->translator->trans('Export Menu'), [
|
||||
|
@ -59,6 +59,16 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
$config['allow_multiple_simultaneous_accompanying_periods']
|
||||
);
|
||||
|
||||
$container->setParameter(
|
||||
'chill_person.create_person_allowed',
|
||||
$config['create_person_allowed']
|
||||
);
|
||||
|
||||
$container->setParameter(
|
||||
'chill_person.create_parcours_allowed',
|
||||
$config['create_parcours_allowed']
|
||||
);
|
||||
|
||||
// register all configuration in a unique parameter
|
||||
$container->setParameter('chill_person', $config);
|
||||
|
||||
|
@ -62,6 +62,12 @@ class Configuration implements ConfigurationInterface
|
||||
->end() // children for 'validation', parent = validation
|
||||
->end() //validation, parent = children of root
|
||||
->end() // children of root, parent = root
|
||||
->booleanNode('create_person_allowed')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->booleanNode('create_parcours_allowed')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->arrayNode('person_fields')
|
||||
->canBeDisabled()
|
||||
->children()
|
||||
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Menu;
|
||||
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Knp\Menu\MenuItem;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
@ -22,23 +23,18 @@ use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
*/
|
||||
class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var AuthorizationCheckerInterface
|
||||
*/
|
||||
protected $authorizationChecker;
|
||||
protected AuthorizationCheckerInterface $authorizationChecker;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
/**
|
||||
* SectionMenuBuilder constructor.
|
||||
*/
|
||||
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator)
|
||||
public function __construct(AuthorizationCheckerInterface $authorizationChecker, TranslatorInterface $translator, ParameterBagInterface $parameterBag)
|
||||
{
|
||||
$this->authorizationChecker = $authorizationChecker;
|
||||
$this->translator = $translator;
|
||||
$this->parameterBag = $parameterBag;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +42,7 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
*/
|
||||
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
||||
{
|
||||
if ($this->authorizationChecker->isGranted(PersonVoter::CREATE)) {
|
||||
if ($this->authorizationChecker->isGranted(PersonVoter::CREATE) && $this->parameterBag->get('chill_person.create_person_allowed')) {
|
||||
$menu->addChild($this->translator->trans('Add a person'), [
|
||||
'route' => 'chill_person_new',
|
||||
])
|
||||
@ -56,13 +52,15 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
]);
|
||||
}
|
||||
|
||||
$menu->addChild($this->translator->trans('Create an accompanying course'), [
|
||||
'route' => 'chill_person_accompanying_course_new',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 11,
|
||||
'icons' => ['plus'],
|
||||
]);
|
||||
if ($this->parameterBag->get('chill_person.create_parcours_allowed')) {
|
||||
$menu->addChild($this->translator->trans('Create an accompanying course'), [
|
||||
'route' => 'chill_person_accompanying_course_new',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 11,
|
||||
'icons' => ['plus'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
|
Loading…
x
Reference in New Issue
Block a user