mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-13 18:24:58 +00:00
This commit adjusts the conditions in CalendarVoter and ActivityVoter security checks. Now it takes into account both STEP_DRAFT and STEP_CLOSED statuses in determining permissions. This enhancement ensures tighter control over specific actions in these two scenarios, enhancing the overall application security.
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\ActivityBundle\Menu;
|
|
|
|
use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
|
|
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
|
|
use Knp\Menu\MenuItem;
|
|
use Symfony\Component\Security\Core\Security;
|
|
|
|
final readonly class AccompanyingCourseQuickMenuBuilder implements LocalMenuBuilderInterface
|
|
{
|
|
public function __construct(private Security $security)
|
|
{
|
|
}
|
|
|
|
public static function getMenuIds(): array
|
|
{
|
|
return ['accompanying_course_quick_menu'];
|
|
}
|
|
|
|
public function buildMenu($menuId, MenuItem $menu, array $parameters)
|
|
{
|
|
/** @var \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingCourse */
|
|
$accompanyingCourse = $parameters['accompanying-course'];
|
|
|
|
if ($this->security->isGranted(ActivityVoter::CREATE, $accompanyingCourse)) {
|
|
$menu
|
|
->addChild('Create a new activity in accompanying course', [
|
|
'route' => 'chill_activity_activity_new',
|
|
'routeParameters' => [
|
|
// 'activityType_id' => '',
|
|
'accompanying_period_id' => $accompanyingCourse->getId(),
|
|
],
|
|
])
|
|
->setExtras([
|
|
'order' => 10,
|
|
'icon' => 'plus',
|
|
])
|
|
;
|
|
}
|
|
}
|
|
}
|