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