mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
transition added + attempt voter
This commit is contained in:
parent
e9e3b85518
commit
a20d7222a8
@ -23,6 +23,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
|
||||
/**
|
||||
* Class AccompanyingCourseController
|
||||
@ -39,16 +40,20 @@ class AccompanyingCourseController extends Controller
|
||||
|
||||
private AccompanyingPeriodWorkRepository $workRepository;
|
||||
|
||||
private Registry $registry;
|
||||
|
||||
public function __construct(
|
||||
SerializerInterface $serializer,
|
||||
EventDispatcherInterface $dispatcher,
|
||||
ValidatorInterface $validator,
|
||||
AccompanyingPeriodWorkRepository $workRepository
|
||||
AccompanyingPeriodWorkRepository $workRepository,
|
||||
Registry $registry
|
||||
) {
|
||||
$this->serializer = $serializer;
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->validator = $validator;
|
||||
$this->workRepository = $workRepository;
|
||||
$this->registry = $registry;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,6 +180,11 @@ class AccompanyingCourseController extends Controller
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$workflow = $this->registry->get($accompanyingCourse);
|
||||
|
||||
if ($workflow->can($accompanyingCourse, 'close')) {
|
||||
$workflow->apply($accompanyingCourse, 'close');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,12 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) {
|
||||
if($this->security->isGranted(self::EDIT, $subject)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if confidential, only the referent can see it
|
||||
if ($subject->isConfidential()) {
|
||||
return $token->getUser() === $subject->getUser();
|
||||
|
@ -32,11 +32,8 @@ services:
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
Chill\PersonBundle\Controller\AccompanyingCourseController:
|
||||
arguments:
|
||||
$serializer: '@Symfony\Component\Serializer\SerializerInterface'
|
||||
$dispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
|
||||
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
||||
$workRepository: '@Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository'
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
|
||||
|
Loading…
x
Reference in New Issue
Block a user