transition added + attempt voter

This commit is contained in:
2021-11-19 08:37:56 +01:00
parent e9e3b85518
commit a20d7222a8
3 changed files with 19 additions and 6 deletions

View File

@@ -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');
}
}