Fixed [search page] quickMenu: improve position and design, manage duplicate buttons

This commit is contained in:
2023-05-24 12:44:02 +02:00
parent 9324c33caf
commit 1337360690
5 changed files with 30 additions and 31 deletions

View File

@@ -3,10 +3,19 @@
namespace Chill\PersonBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Knp\Menu\MenuItem;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
class PersonQuickMenuBuilder implements LocalMenuBuilderInterface
{
private AuthorizationCheckerInterface $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{
$this->authorizationChecker = $authorizationChecker;
}
public static function getMenuIds(): array
{
return ['person_quick_menu'];
@@ -17,16 +26,20 @@ class PersonQuickMenuBuilder implements LocalMenuBuilderInterface
/** @var \Chill\PersonBundle\Entity\Person $person */
$person = $parameters['person'];
$menu->addChild('Create Accompanying Course', [
'route' => 'chill_person_accompanying_course_new',
'routeParameters' => [
'person_id' => $person->getId(),
], ])
if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::CREATE, $person)) {
$menu->addChild(
'Create Accompanying Course', [
'route' => 'chill_person_accompanying_course_new',
'routeParameters' => [
'person_id' => [ $person->getId() ],
],
]
)
->setExtras([
'order' => 10,
'icon' => 'plus'
])
;
]);
}
}
}