fix some authorization check in menu

This commit is contained in:
2022-03-25 13:11:03 +01:00
parent b423821ae9
commit d11eebefae
4 changed files with 43 additions and 11 deletions

View File

@@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Menu;
use Chill\MainBundle\Routing\LocalMenuBuilderInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Knp\Menu\MenuItem;
use LogicException;
@@ -40,9 +41,11 @@ class MenuBuilder implements LocalMenuBuilderInterface
public function buildAccompanyingCourseMenu($menu, $parameters)
{
/** @var AccompanyingPeriod $course */
$course = $parameters['accompanyingCourse'];
if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)) {
if ($this->authorizationChecker->isGranted(TaskVoter::SHOW, $course)
&& AccompanyingPeriod::STEP_DRAFT !== $course->getStep()) {
$menu->addChild(
$this->translator->trans('Tasks'),
[