src/Controller/API/LandingPageController.php line 198

Open in your IDE?
  1. <?php
  2. namespace App\Controller\API;
  3. use App\Controller\BaseController;
  4. use App\Entity\Log\LogInteraction;
  5. use App\Services\API\LandingPageService;
  6. use App\Utils\APIResponse;
  7. use App\Utils\CommonFunctions;
  8. use Exception;
  9. use OpenApi\Annotations as OA;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. /**
  14.  * @Route("/landing-pages")
  15.  */
  16. class LandingPageController extends BaseController
  17. {
  18.     /**
  19.      * Obtiene la lista de Landing Pages activas
  20.      *
  21.      * @Route("", name="get_landing_pages", methods={"GET"})
  22.      * @param Request $request
  23.      * @param LandingPageService $landingPageService
  24.      * @return Response
  25.      *
  26.      * @OA\Get(
  27.      *     path="/api/v1/landing-pages",
  28.      *     summary="Obtener lista de Landing Pages activas",
  29.      *     @OA\Response(
  30.      *         response=200,
  31.      *         description="Lista de landing pages obtenida exitosamente",
  32.      *         @OA\MediaType(
  33.      *             mediaType="application/json",
  34.      *             @OA\Schema(
  35.      *                 @OA\Property(property="status", type="integer", example=200),
  36.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  37.      *                 @OA\Property(
  38.      *                     property="content",
  39.      *                     type="array",
  40.      *                     @OA\Items(
  41.      *                         @OA\Property(property="id", type="integer", example=1),
  42.      *                         @OA\Property(property="titulo", type="string", example="Animales"),
  43.      *                         @OA\Property(property="descripcion", type="string", example="Conocé todo sobre animales")
  44.      *                     )
  45.      *                 )
  46.      *             )
  47.      *         )
  48.      *     ),
  49.      *     @OA\Response(
  50.      *         response=500,
  51.      *         description="Error interno del servidor",
  52.      *         @OA\MediaType(
  53.      *             mediaType="application/json",
  54.      *             @OA\Schema(
  55.      *                 @OA\Property(property="status", type="integer", example=500),
  56.      *                 @OA\Property(
  57.      *                     property="errors",
  58.      *                     type="array",
  59.      *                     @OA\Items(type="string", example="Error al obtener landing pages")
  60.      *                 ),
  61.      *                 @OA\Property(property="content", type="null")
  62.      *             )
  63.      *         )
  64.      *     )
  65.      * )
  66.      */
  67.     public function getLandingPagesAction(Request $requestLandingPageService $landingPageService): Response
  68.     {
  69.         $statusCode APIResponse::$SUCCESS;
  70.         $status APIResponse::$SUCCESS;
  71.         $errors = array();
  72.         $result null;
  73.         try {
  74.             $result $landingPageService->getActiveLandingPages();
  75.         } catch (Exception $e) {
  76.             $statusCode APIResponse::$INTERNAL_ERROR;
  77.             $status APIResponse::$INTERNAL_ERROR;
  78.             $errors = array($e->getMessage());
  79.             $errorInfo CommonFunctions::getErrorException($e);
  80.             $this->logInteractionService->addErrorLog(
  81.                 LogInteraction::$LIST,
  82.                 CommonFunctions::getClassMethod(__METHOD__),
  83.                 $e->getMessage(),
  84.                 $errorInfo
  85.             );
  86.         }
  87.         return $this->generateJsonResponse($result$statusCode$status$errors);
  88.     }
  89.     /**
  90.      * Obtiene la información completa de una Landing Page por título
  91.      * Incluye header vigente y bloques activos ordenados por posición
  92.      *
  93.      * @Route("/{titulo}", name="get_landing_page_by_titulo", methods={"GET"})
  94.      * @param Request $request
  95.      * @param string $titulo Título de la landing page (case-sensitive)
  96.      * @param LandingPageService $landingPageService
  97.      * @return Response
  98.      *
  99.      * @OA\Get(
  100.      *     path="/api/v1/landing-pages/{titulo}",
  101.      *     summary="Obtener información completa de una Landing Page por título",
  102.      *     @OA\Parameter(
  103.      *         name="titulo",
  104.      *         in="path",
  105.      *         required=true,
  106.      *         description="Título exacto de la landing page (case-sensitive). Ejemplo: 'Animales'",
  107.      *         @OA\Schema(type="string")
  108.      *     ),
  109.      *     @OA\Response(
  110.      *         response=200,
  111.      *         description="Landing Page encontrada exitosamente",
  112.      *         @OA\MediaType(
  113.      *             mediaType="application/json",
  114.      *             @OA\Schema(
  115.      *                 @OA\Property(property="status", type="integer", example=200),
  116.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  117.      *                 @OA\Property(
  118.      *                     property="content",
  119.      *                     type="object",
  120.      *                     @OA\Property(property="id", type="integer", example=1),
  121.      *                     @OA\Property(property="titulo", type="string", example="Animales"),
  122.      *                     @OA\Property(property="descripcion", type="string", example="Conocé todo sobre animales"),
  123.      *                     @OA\Property(
  124.      *                         property="header",
  125.      *                         type="object",
  126.      *                         @OA\Property(property="titulo", type="string", example="Animales"),
  127.      *                         @OA\Property(property="bajada", type="string", example="Descripcion de animales"),
  128.      *                         @OA\Property(property="colorFondo", type="string", example="cyan"),
  129.      *                         @OA\Property(property="colorAside", type="string", example="bg-aside-hero-dark"),
  130.      *                         @OA\Property(property="tipoDiseno", type="string", example="corner"),
  131.      *                         @OA\Property(property="landingPage", type="string", example="Animales"),
  132.      *                         @OA\Property(
  133.      *                             property="botones",
  134.      *                             type="array",
  135.      *                             @OA\Items(
  136.      *                                 type="array",
  137.      *                                 @OA\Items(
  138.      *                                     @OA\Property(property="texto", type="string", example="Botón primario"),
  139.      *                                     @OA\Property(property="url", type="string", example="https://www.google.com/?hl=es"),
  140.      *                                     @OA\Property(property="estilo", type="string", example="primary")
  141.      *                                 )
  142.      *                             )
  143.      *                         ),
  144.      *                         @OA\Property(
  145.      *                             property="multimedia",
  146.      *                             type="array",
  147.      *                             @OA\Items(
  148.      *                                 @OA\Property(property="imagenUrl", type="string", example="https://localhost/api/v1/imagen/header/multimedia_header_5.jpg"),
  149.      *                                 @OA\Property(property="tipo", type="string", example="imagen"),
  150.      *                                 @OA\Property(property="loop", type="boolean", example=false),
  151.      *                                 @OA\Property(property="autoplay", type="boolean", example=false),
  152.      *                                 @OA\Property(property="muted", type="boolean", example=false),
  153.      *                                 @OA\Property(property="controls", type="boolean", example=false)
  154.      *                             )
  155.      *                         )
  156.      *                     ),
  157.      *                     @OA\Property(
  158.      *                         property="bloques",
  159.      *                         type="array",
  160.      *                         @OA\Items(
  161.      *                             @OA\Property(property="id", type="integer", example=1),
  162.      *                             @OA\Property(property="titulo", type="string", example="Bloque 1"),
  163.      *                             @OA\Property(property="descripcion", type="string", example="Descripción del bloque"),
  164.      *                             @OA\Property(property="colorFondo", type="string", example="cyan"),
  165.      *                             @OA\Property(property="claseFondo", type="string", example="bg-cyan"),
  166.      *                             @OA\Property(property="posicion", type="integer", example=0),
  167.      *                             @OA\Property(property="activo", type="boolean", example=true)
  168.      *                         )
  169.      *                     )
  170.      *                 )
  171.      *             )
  172.      *         )
  173.      *     ),
  174.      *     @OA\Response(
  175.      *         response=500,
  176.      *         description="Landing Page no encontrada o error interno",
  177.      *         @OA\MediaType(
  178.      *             mediaType="application/json",
  179.      *             @OA\Schema(
  180.      *                 @OA\Property(property="status", type="integer", example=500),
  181.      *                 @OA\Property(
  182.      *                     property="errors",
  183.      *                     type="array",
  184.      *                     @OA\Items(type="string", example="No se encontró landing page activa con el título 'Animales'")
  185.      *                 ),
  186.      *                 @OA\Property(property="content", type="null")
  187.      *             )
  188.      *         )
  189.      *     )
  190.      * )
  191.      */
  192.     public function getLandingPageByTituloAction(Request $requeststring $tituloLandingPageService $landingPageService): Response
  193.     {
  194.         $statusCode APIResponse::$SUCCESS;
  195.         $status APIResponse::$SUCCESS;
  196.         $errors = array();
  197.         $result null;
  198.         try {
  199.             $result $landingPageService->getLandingPageByTitulo($titulo);
  200.         } catch (Exception $e) {
  201.             $statusCode APIResponse::$INTERNAL_ERROR;
  202.             $status APIResponse::$INTERNAL_ERROR;
  203.             $errors = array($e->getMessage());
  204.             $errorInfo CommonFunctions::getErrorException($e);
  205.             $this->logInteractionService->addErrorLog(
  206.                 LogInteraction::$LIST,
  207.                 CommonFunctions::getClassMethod(__METHOD__),
  208.                 $e->getMessage(),
  209.                 $errorInfo
  210.             );
  211.         }
  212.         return $this->generateJsonResponse($result$statusCode$status$errors);
  213.     }
  214. }