mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
first impl for create form
This commit is contained in:
@@ -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
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user