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
dcbed94050
commit
6c48a22f86
@ -23,6 +23,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
use Symfony\Component\Workflow\Registry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AccompanyingCourseController
|
* Class AccompanyingCourseController
|
||||||
@ -39,16 +40,20 @@ class AccompanyingCourseController extends Controller
|
|||||||
|
|
||||||
private AccompanyingPeriodWorkRepository $workRepository;
|
private AccompanyingPeriodWorkRepository $workRepository;
|
||||||
|
|
||||||
|
private Registry $registry;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SerializerInterface $serializer,
|
SerializerInterface $serializer,
|
||||||
EventDispatcherInterface $dispatcher,
|
EventDispatcherInterface $dispatcher,
|
||||||
ValidatorInterface $validator,
|
ValidatorInterface $validator,
|
||||||
AccompanyingPeriodWorkRepository $workRepository
|
AccompanyingPeriodWorkRepository $workRepository,
|
||||||
|
Registry $registry
|
||||||
) {
|
) {
|
||||||
$this->serializer = $serializer;
|
$this->serializer = $serializer;
|
||||||
$this->dispatcher = $dispatcher;
|
$this->dispatcher = $dispatcher;
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
$this->workRepository = $workRepository;
|
$this->workRepository = $workRepository;
|
||||||
|
$this->registry = $registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,6 +180,11 @@ class AccompanyingCourseController extends Controller
|
|||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
|
||||||
$this->getDoctrine()->getManager()->flush();
|
$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;
|
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 confidential, only the referent can see it
|
||||||
if ($subject->isConfidential()) {
|
if ($subject->isConfidential()) {
|
||||||
return $token->getUser() === $subject->getUser();
|
return $token->getUser() === $subject->getUser();
|
||||||
|
@ -32,11 +32,8 @@ services:
|
|||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
Chill\PersonBundle\Controller\AccompanyingCourseController:
|
Chill\PersonBundle\Controller\AccompanyingCourseController:
|
||||||
arguments:
|
autoconfigure: true
|
||||||
$serializer: '@Symfony\Component\Serializer\SerializerInterface'
|
autowire: true
|
||||||
$dispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface'
|
|
||||||
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
|
|
||||||
$workRepository: '@Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository'
|
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
|
||||||
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
|
Chill\PersonBundle\Controller\AccompanyingCourseApiController:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user