mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-06 14:54:57 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\ChillDocStoreBundle;
|
||||
use Chill\DocStoreBundle\Entity\DocumentCategory;
|
||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||
use Chill\DocStoreBundle\Form\DocumentCategoryType;
|
||||
@@ -11,19 +19,73 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Chill\DocStoreBundle\ChillDocStoreBundle;
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/admin/document/category")
|
||||
*/
|
||||
class DocumentCategoryController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/{bundleId}/{idInsideBundle}", name="document_category_delete", methods="DELETE")
|
||||
*
|
||||
* @param mixed $bundleId
|
||||
* @param mixed $idInsideBundle
|
||||
*/
|
||||
public function delete(Request $request, $bundleId, $idInsideBundle): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$documentCategory = $em
|
||||
->getRepository('ChillDocStoreBundle:DocumentCategory')
|
||||
->findOneBy(
|
||||
['bundleId' => $bundleId, 'idInsideBundle' => $idInsideBundle]
|
||||
);
|
||||
|
||||
if ($this->isCsrfTokenValid('delete' . $bundleId . $idInsideBundle, $request->request->get('_token'))) {
|
||||
$em->remove($documentCategory);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('document_category_index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{bundleId}/{idInsideBundle}/edit", name="document_category_edit", methods="GET|POST")
|
||||
*
|
||||
* @param mixed $bundleId
|
||||
* @param mixed $idInsideBundle
|
||||
*/
|
||||
public function edit(Request $request, $bundleId, $idInsideBundle): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$documentCategory = $em
|
||||
->getRepository('ChillDocStoreBundle:DocumentCategory')
|
||||
->findOneBy(
|
||||
['bundleId' => $bundleId, 'idInsideBundle' => $idInsideBundle]
|
||||
);
|
||||
|
||||
$form = $this->createForm(DocumentCategoryType::class, $documentCategory);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('document_category_index', [
|
||||
'bundleId' => $documentCategory->getBundleId(),
|
||||
'idInsideBundle' => $documentCategory->getIdInsideBundle(), ]);
|
||||
}
|
||||
|
||||
return $this->render('ChillDocStoreBundle:DocumentCategory:edit.html.twig', [
|
||||
'document_category' => $documentCategory,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/", name="document_category_index", methods="GET")
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$categories = $em->getRepository(DocumentCategory::class)->findAll();
|
||||
|
||||
return $this->render(
|
||||
@@ -68,64 +130,22 @@ class DocumentCategoryController extends AbstractController
|
||||
|
||||
/**
|
||||
* @Route("/{bundleId}/{idInsideBundle}", name="document_category_show", methods="GET")
|
||||
*
|
||||
* @param mixed $bundleId
|
||||
* @param mixed $idInsideBundle
|
||||
*/
|
||||
public function show($bundleId, $idInsideBundle): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$documentCategory = $em
|
||||
->getRepository("ChillDocStoreBundle:DocumentCategory")
|
||||
->getRepository('ChillDocStoreBundle:DocumentCategory')
|
||||
->findOneBy(
|
||||
['bundleId' => $bundleId, 'idInsideBundle' => $idInsideBundle]);
|
||||
['bundleId' => $bundleId, 'idInsideBundle' => $idInsideBundle]
|
||||
);
|
||||
|
||||
return $this->render(
|
||||
'ChillDocStoreBundle:DocumentCategory:show.html.twig',
|
||||
['document_category' => $documentCategory]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{bundleId}/{idInsideBundle}/edit", name="document_category_edit", methods="GET|POST")
|
||||
*/
|
||||
public function edit(Request $request, $bundleId, $idInsideBundle): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$documentCategory = $em
|
||||
->getRepository("ChillDocStoreBundle:DocumentCategory")
|
||||
->findOneBy(
|
||||
['bundleId' => $bundleId, 'idInsideBundle' => $idInsideBundle]);
|
||||
|
||||
$form = $this->createForm(DocumentCategoryType::class, $documentCategory);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return $this->redirectToRoute('document_category_index', [
|
||||
'bundleId' => $documentCategory->getBundleId(),
|
||||
'idInsideBundle' => $documentCategory->getIdInsideBundle(),]);
|
||||
}
|
||||
|
||||
return $this->render('ChillDocStoreBundle:DocumentCategory:edit.html.twig', [
|
||||
'document_category' => $documentCategory,
|
||||
'form' => $form->createView(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{bundleId}/{idInsideBundle}", name="document_category_delete", methods="DELETE")
|
||||
*/
|
||||
public function delete(Request $request, $bundleId, $idInsideBundle): Response
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$documentCategory = $em
|
||||
->getRepository("ChillDocStoreBundle:DocumentCategory")
|
||||
->findOneBy(
|
||||
['bundleId' => $bundleId, 'idInsideBundle' => $idInsideBundle]);
|
||||
|
||||
if ($this->isCsrfTokenValid('delete'.$bundleId.$idInsideBundle, $request->request->get('_token'))) {
|
||||
$em->remove($documentCategory);
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('document_category_index');
|
||||
['document_category' => $documentCategory]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user