src/Controller/Publico/ComprobarGradeadaController.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Publico;
  3. use App\Entity\Ajustes\Gradeada;
  4. use App\Form\Privado\Entidades\Ajustes\ComprobarGradeadaType;
  5. use App\Repository\Ajustes\GradeadaRepository;
  6. use Sonata\SeoBundle\Seo\SeoPageInterface;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Contracts\Translation\TranslatorInterface;
  12. /**
  13.  * @Route("/comprobar_gradeada", name="check_")
  14.  */
  15. class ComprobarGradeadaController extends AbstractController
  16. {
  17.     public const BASEDIR Gradeada::BASEDIR;
  18.     public const ICON Gradeada::ICON;
  19.     protected $repo;
  20.     protected $trans;
  21.     protected $seo;
  22.     public function __construct(GradeadaRepository $repo,TranslatorInterface $transSeoPageInterface $seo)
  23.     {
  24.         $this->repo $repo;
  25.         $this->trans $trans;
  26.         $this->seo $seo;
  27.     }
  28.     /**
  29.      * @Route("/", name="index", options={"expose"=true})
  30.      */
  31.     public function indexAction(Request $request): Response
  32.     {
  33.         //SEO
  34.         $titulo =$this->trans->trans('gradeada.check.seo.title', [], 'gradeada');
  35.         $descripcion =$this->trans->trans('gradeada.check.seo.description', [], 'gradeada');
  36.         $this->seo 
  37.             ->setTitle($titulo)
  38.             ->addMeta('name''description'$descripcion)
  39.             ->addMeta('property''og:title'$titulo)
  40.             ->addMeta('property''og:description'$descripcion)
  41.         ;
  42.         
  43.         //Creem un formulari
  44.         $form $this->createForm(ComprobarGradeadaType::class);
  45.         $form->handleRequest($request);
  46.         if ($form->isSubmitted()) {
  47.             if ($form->isValid()) {
  48.                 $certificado $form->getData()['certificado'] != null $form->getData()['certificado'] : '';
  49.                 if($certificado != ''){
  50.                     $resultBD $this->repo->findOneBy(['GradNumCertificado' => $certificado]);
  51.                     if($resultBD != null){
  52.                         //hi h una grdeada en ixe certificat
  53.                         //Averigur quante de ixa carta tenim
  54.                         $array $this->repo->getPopulation($resultBD);
  55.                         return $this->render(self::BASEDIR.'/comprobar/grad_comprobar_registro.html.twig', [
  56.                             'array'    => $array,
  57.                             'gradeada' => $resultBD,
  58.                             'form'     => $form->createView(),
  59.                             'BaseDir'  => self::BASEDIR,
  60.                             'ICON'     => self::ICON,
  61.                         ]);
  62.                     }
  63.                 }
  64.                 
  65.             } else {
  66.                 $this->addFlash('danger'$this->trans->trans('descuento.edit.form.error2', [], 'descuento'));
  67.             }
  68.         }
  69.         return $this->render(self::BASEDIR.'/comprobar/grad_comprobar_registro.html.twig', [
  70.             'form' => $form->createView(),
  71.             'BaseDir' => self::BASEDIR,
  72.             'ICON' => self::ICON,
  73.         ]);
  74.     }
  75. }