src/Controller/MasseurListController.php line 74

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-03-22
  5.  * Time: 15:26
  6.  */
  7. namespace App\Controller;
  8. use App\Entity\Location\City;
  9. use App\Dto\ProfileListSpecification;
  10. use App\Service\ProfileListSpecificationService;
  11. use Flagception\Bundle\FlagceptionBundle\Annotations\Feature;
  12. use OpenApi\Attributes as OA;
  13. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  14. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  15. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  16. use Symfony\Component\HttpFoundation\Request;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. #[Cache(maxage: 60, public: true)]
  20. class MasseurListController extends AbstractController
  21. {
  22.     private const RESULT_SOURCE_WITHOUT_INTERMEDIARIES = 'massagers_without_intermediaries';
  23.     private const RESULT_SOURCE_MATURE = 'massagers_mature';
  24.     private const RESULT_SOURCE_CHEAP = 'massagers_cheap';
  25.     private const RESULT_SOURCE_OUTCALL = 'massagers_outcall';
  26.     public function __construct(
  27.         private ProfileListSpecificationService $profileListSpecificationService,
  28.     ) {}
  29.     /**
  30.      * @Feature("has_masseurs")
  31.      */
  32.     #[ParamConverter("city", converter: "city_converter")]
  33.     #[Route("/api/profiles/listing/city/{city}/category/massagers", name: "api.profile_listing.massagers", methods: "GET", format: "json")]
  34.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  35.     #[OA\Tag(name: "ProfileListing")]
  36.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  37.     public function page(Request $request, City $city): Response
  38.     {
  39.         return $this->forward('App\Controller\ProfileListController::listForMasseur', [
  40.             'city' => $city,
  41.             'page' => $request->attributes->getInt('page', 1),
  42.             '_route' => $request->attributes->get('_route'),
  43.         ]);
  44.     }
  45.     /** @Feature("massagers_without_intermediaries") */
  46.     #[ParamConverter("city", converter: "city_converter")]
  47.     #[Route("/api/profiles/listing/city/{city}/category/massagers/private", name: "api.profile_listing.massagers.private", methods: "GET", format: "json")]
  48.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  49.     #[OA\Tag(name: "ProfileListing")]
  50.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  51.     public function listWithoutIntermediaries(Request $request, City $city): Response
  52.     {
  53.         return $this->listing(
  54.             $request,
  55.             $city,
  56.             $this->profileListSpecificationService->listMassagersWithoutIntermediaries(),
  57.             self::RESULT_SOURCE_WITHOUT_INTERMEDIARIES,
  58.             '/city/{city}/category/massagers_private',
  59.         );
  60.     }
  61.     /** @Feature("massagers_checked") */
  62.     #[ParamConverter("city", converter: "city_converter")]
  63.     #[Route("/api/profiles/listing/city/{city}/category/massagers/mature", name: "api.profile_listing.massagers.mature", methods: "GET", format: "json")]
  64.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  65.     #[OA\Tag(name: "ProfileListing")]
  66.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  67.     public function listMature(Request $request, City $city): Response
  68.     {
  69.         return $this->listing(
  70.             $request,
  71.             $city,
  72.             $this->profileListSpecificationService->listMassagersMature($city),
  73.             self::RESULT_SOURCE_MATURE,
  74.         );
  75.     }
  76.     /** @Feature("massagers_cheap") */
  77.     #[ParamConverter("city", converter: "city_converter")]
  78.     #[Route("/api/profiles/listing/city/{city}/category/massagers/price-low", name: "api.profile_listing.massagers.price_low", methods: "GET", format: "json")]
  79.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  80.     #[OA\Tag(name: "ProfileListing")]
  81.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  82.     public function listCheap(Request $request, City $city): Response
  83.     {
  84.         return $this->listing(
  85.             $request,
  86.             $city,
  87.             $this->profileListSpecificationService->listMassagersCheap($city),
  88.             self::RESULT_SOURCE_CHEAP,
  89.         );
  90.     }
  91.     /** @Feature("massagers_outcall") */
  92.     #[ParamConverter("city", converter: "city_converter")]
  93.     #[Route("/api/profiles/listing/city/{city}/category/massagers/outcall", name: "api.profile_listing.massagers.outcall", methods: "GET", format: "json")]
  94.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  95.     #[OA\Tag(name: "ProfileListing")]
  96.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  97.     public function listOutcall(Request $request, City $city): Response
  98.     {
  99.         return $this->listing(
  100.             $request,
  101.             $city,
  102.             $this->profileListSpecificationService->listMassagersOutcall(),
  103.             self::RESULT_SOURCE_OUTCALL,
  104.             '/city/{city}/category/massagers_outcall',
  105.         );
  106.     }
  107.     private function listing(
  108.         Request $request,
  109.         City $city,
  110.         ProfileListSpecification $specs,
  111.         string $source,
  112.         ?string $apiEndpoint = null,
  113.     ): Response {
  114.         return $this->forward(ProfileListController::class.'::profileLandingListing', [
  115.             'city' => $city,
  116.             'specs' => $specs,
  117.             'source' => $source,
  118.             'apiEndpoint' => $apiEndpoint,
  119.             'masseur' => null,
  120.             '_route' => $request->attributes->get('_route'),
  121.             '_route_params' => $request->attributes->get('_route_params'),
  122.             '_format' => $request->attributes->get('_format'),
  123.             'page' => $request->attributes->getInt('page', 1),
  124.         ], $request->query->all());
  125.     }
  126. }