first impl for create form

This commit is contained in:
2021-06-18 19:41:58 +02:00
parent 07cc394abd
commit 3abfdbf6fd
16 changed files with 448 additions and 8 deletions

View File

@@ -0,0 +1,52 @@
<?php
namespace Chill\PersonBundle\Controller;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Translation\TranslatorInterface;
class AccompanyingCourseWorkController extends AbstractController
{
private TranslatorInterface $trans;
private SerializerInterface $serializer;
public function __construct(TranslatorInterface $trans, SerializerInterface $serializer)
{
$this->trans = $trans;
$this->serializer = $serializer;
}
/**
* @Route(
* "{_locale}/person/accompanying-period/{id}/work/new",
* methods={"GET", "POST"}
* )
*/
public function createWork(AccompanyingPeriod $period)
{
// TODO ACL
if ($period->getSocialIssues()->count() === 0) {
$this->addFlash('error', $this->trans->trans(
"accompanying_work.You must add at least ".
"one social issue on accompanying period")
);
return $this->redirectToRoute('chill_person_accompanying_course_index', [
'accompanying_period_id' => $period->getId()
]);
}
$json = $this->serializer->normalize($period, 'json', [ "groups" => [ "read" ]]);
return $this->render('@ChillPerson/AccompanyingCourseWork/create.html.twig', [
'accompanyingCourse' => $period,
'json' => $json
]);
}
}