src/Controller/API/ImagenController.php line 44

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\ImagenService;
  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("/imagenes")
  15.  */
  16. class ImagenController extends BaseController
  17. {
  18.     /**
  19.      * @Route("", name="get_imagenes", methods={"GET"})
  20.      * @param Request $request
  21.      * @param ImagenService $imagenService
  22.      * @return Response
  23.      *
  24.      * @OA\Get(
  25.      *     path="/api/v1/imagenes",
  26.      *     summary="Obtener todas las imagenes",
  27.      *     @OA\Response(
  28.      *         response=200,
  29.      *         description="Response",
  30.      *         @OA\MediaType(
  31.      *             mediaType="application/json",
  32.      *             @OA\Schema(
  33.      *                 @OA\Property(property="status", type="integer"),
  34.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  35.      *                 @OA\Property(property="content", type="object")
  36.      *            )
  37.      *        )
  38.      *    )
  39.      * )
  40.      */
  41.     public function imagenesAction(Request $requestImagenService $imagenService)
  42.     {
  43.         $statusCode APIResponse::$SUCCESS;
  44.         $status APIResponse::$SUCCESS;
  45.         $errors = array();
  46.         $result null;
  47.         try {
  48.             $result $imagenService->getImagenes();
  49.         } catch (Exception $e) {
  50.             $statusCode APIResponse::$INTERNAL_ERROR;
  51.             $status APIResponse::$INTERNAL_ERROR;
  52.             $errors = array($e->getMessage());
  53.             $errorInfo CommonFunctions::getErrorException($e);
  54.             $this->logInteractionService->addErrorLog(
  55.                 LogInteraction::$LIST,
  56.                 CommonFunctions::getClassMethod(__METHOD__),
  57.                 $e->getMessage(),
  58.                 $errorInfo
  59.             );
  60.         }
  61.         return $this->generateJsonResponse($result$statusCode$status$errors);
  62.     }
  63. }