src/Controller/Administration/CspCountryController.php line 32

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Controller\Administration;
  4. use Symfony\Component\HttpFoundation\{
  5.     Request,
  6.     Response
  7. };
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  11. use App\Common\Controllers\CrmAbstractController;
  12. use App\Entity\{CspCspCountryCountry};
  13. use App\Services\Administration\CspCountryService;
  14. class CspCountryController extends CrmAbstractController
  15. {
  16.     /**
  17.      * @see CrmAbstractController
  18.      */
  19.     protected function initModuleDetails(): array
  20.     {
  21.         return [
  22.             'entityClassName' => CspCountry::class,
  23.             'moduleService' => CspCountryService::class,
  24.         ];
  25.     }
  26.     #[Route('/administration/csp/{id}/countries'name'administration_csp_countries'options: ['expose' => true])]
  27.     public function index(CspCountryService $cspCountryServiceCsp $csp): Response
  28.     {
  29.         return new Response($cspCountryService->getList($csp));
  30.     }
  31.     #[Security("is_granted('ROLE_PM') or is_granted('ROLE_EDM') or is_granted('ROLE_EPA')")]
  32.     #[Route(
  33.         '/administration/csp-country/{id}/add',
  34.         name'administration_csp_countries_add',
  35.         methods: ['POST'],
  36.         options: ['expose' => true])
  37.     ]
  38.     public function add(
  39.         Request $request,
  40.         CspCountryService $cspCountryService,
  41.         CspCountry $cspCountry
  42.     ): Response {
  43.         $cspCountryService->saveCspCountry($cspCountry);
  44.         return $this->redirectToRoute('administration_csp_countries', ['id' => $cspCountry->getCsp()->getId()]);
  45.     }
  46.     #[Security("is_granted('ROLE_PM') or is_granted('ROLE_EDM') or is_granted('ROLE_EPA')")]
  47.     #[Route(
  48.         '/administration/csp-country/{id}',
  49.         name'administration_csp_country_item',
  50.         options: ['expose' => true])
  51.     ]
  52.     public function getCspCountry(
  53.         CspCountryService $cspCountryService,
  54.         CspCountry $cspCountry
  55.     ): Response {
  56.         return new Response($cspCountryService->getSerializedEntity($cspCountry));
  57.     }
  58.     #[Security("is_granted('ROLE_PM') or is_granted('ROLE_EDM') or is_granted('ROLE_EPA')")]
  59.     #[Route(
  60.         '/administration/csp-country/{id}/delete',
  61.         name'administration_csp_countries_delete',
  62.         options: ['expose' => true])
  63.     ]
  64.     public function delete(
  65.         CspCountryService $cspCountryService,
  66.         CspCountry $cspCountry
  67.     ): Response {
  68.         $cspCountryService->deleteCspCountry($cspCountry);
  69.         return $this->redirectToRoute('administration_csp_countries', ['id' => $cspCountry->getCsp()->getId()]);
  70.     }
  71.     #[Route(
  72.         '/administration/csp/{id}/country/{cId}/details',
  73.         name'administration_csp_country_details',
  74.         options: ['expose' => true])
  75.     ]
  76.     #[ParamConverter('csp', class: Csp::class, options: ['mapping' => ['id' => 'id']])]
  77.     #[ParamConverter('country', class: Country::class, options: ['mapping' => ['cId' => 'id']])]
  78.     public function cspCountryDetails(CspCountryService $cspCountryServiceCsp $cspCountry $country): Response
  79.     {
  80.         return $this->render(
  81.             'administration/csp/csp_country_details.html.twig', [
  82.                 'cspCountry' => $cspCountryService->getCspCountryEntityByCspAndCountry($csp$country),
  83.             ]
  84.         );
  85.     }
  86. }