src/Controller/ProfileListController.php line 648

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-03-19
  5.  * Time: 22:28
  6.  */
  7. namespace App\Controller;
  8. use App\Attribute\SplitFirstPagePagination;
  9. use App\Bridge\Porpaginas\Doctrine\ORM\FakeORMQueryPage;
  10. use App\Dto\ProfileListSpecification;
  11. use App\Entity\Location\City;
  12. use App\Entity\Location\County;
  13. use App\Entity\Location\District;
  14. use App\Entity\Location\Station;
  15. use App\Entity\Profile\Appearances;
  16. use App\Entity\Profile\BodyTypes;
  17. use App\Entity\Profile\BreastTypes;
  18. use App\Entity\Profile\Genders;
  19. use App\Entity\Profile\HairColors;
  20. use App\Entity\Profile\Nationalities;
  21. use App\Entity\Profile\ProfileInventoryItem;
  22. use App\Entity\Profile\ProfileInventoryItemType;
  23. use App\Entity\Profile\PrivateHaircuts;
  24. use App\Entity\Service;
  25. use App\Entity\ServiceGroups;
  26. use App\Entity\TakeOutLocations;
  27. use App\Repository\CityRepository;
  28. use App\Repository\ProfileRepository;
  29. use App\Repository\ServiceRepository;
  30. use App\Repository\StationRepository;
  31. use App\Service\CountryCurrencyResolver;
  32. use App\Service\DefaultCityProvider;
  33. use App\Service\EntitySortService;
  34. use App\Service\Features;
  35. use App\Service\GeoCategoryLinkageService;
  36. use App\Service\HomepageCityListingsBlockProvider;
  37. use App\Service\ListingRotationApi;
  38. use App\Service\MixedCityListings;
  39. use App\Service\ListingService;
  40. use App\Service\LocationsProfileCounters;
  41. use App\Service\ProfileList;
  42. use App\Service\ProfileListingAppliedFiltersResolver;
  43. use App\Service\ProfileListingRecommendationsFiller;
  44. use App\Service\ProfileListingDataCreator;
  45. use App\Service\ProfileListSpecificationService;
  46. use App\Service\ProfileFilterService;
  47. use App\Service\ProfileNameLandingProvider;
  48. use App\Service\ProfileTopBoard;
  49. use App\Service\Top100ProfilesService;
  50. use App\Specification\ElasticSearch\ISpecification;
  51. use App\Specification\Profile\ProfileHasApartments;
  52. use App\Specification\Profile\ProfileHasComments;
  53. use App\Specification\Profile\ProfileHasVideo;
  54. use App\Specification\Profile\ProfileIdIn;
  55. use App\Specification\Profile\ProfileIdINOrderedByINValues;
  56. use App\Specification\Profile\ProfileIdNotIn;
  57. use App\Specification\Profile\ProfileIsApproved;
  58. use App\Specification\Profile\ProfileIsElite;
  59. use App\Specification\Profile\ProfileIsLocated;
  60. use App\Specification\Profile\ProfileIsProvidingOneOfServices;
  61. use App\Specification\Profile\ProfileIsProvidingTakeOut;
  62. use App\Specification\Profile\ProfilePriceThresholds;
  63. use App\Specification\Profile\ProfileWithAge;
  64. use App\Specification\Profile\ProfileWithAppearance;
  65. use App\Specification\Profile\ProfileWithBodyType;
  66. use App\Specification\Profile\ProfileWithBreastType;
  67. use App\Specification\Profile\ProfileWithHairColor;
  68. use App\Specification\Profile\ProfileWithNationality;
  69. use App\Specification\Profile\ProfileWithPrivateHaircut;
  70. use Flagception\Bundle\FlagceptionBundle\Annotations\Feature;
  71. use Happyr\DoctrineSpecification\Filter\Filter;
  72. use Happyr\DoctrineSpecification\Logic\OrX;
  73. use OpenApi\Attributes as OA;
  74. use Porpaginas\Doctrine\ORM\ORMQueryResult;
  75. use Porpaginas\Page;
  76. use Psr\Cache\CacheItemPoolInterface;
  77. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  78. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
  79. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  80. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  81. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  82. use Symfony\Component\HttpFoundation\JsonResponse;
  83. use Symfony\Component\HttpFoundation\Request;
  84. use Happyr\DoctrineSpecification\Spec;
  85. use Symfony\Component\HttpFoundation\RequestStack;
  86. use Symfony\Component\HttpFoundation\Response;
  87. use Symfony\Component\Intl\Countries;
  88. use Symfony\Component\Routing\Annotation\Route;
  89. use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
  90. /**
  91.  * @see \App\Console\Export\ExportRotationListingsConfigCommand for listing API endpoints
  92.  */
  93. #[Cache(maxage: 60, public: true)]
  94. class ProfileListController extends AbstractController
  95. {
  96.     use ExtendedPaginationTrait;
  97.     use SpecTrait;
  98.     use ProfileMinPriceTrait;
  99.     use ResponseTrait;
  100.     const ENTRIES_ON_PAGE = 36;
  101.     private const NEW_PROFILES_LIMIT = 100;
  102.     const RESULT_SOURCE_COUNTY = 'county';
  103.     const RESULT_SOURCE_DISTRICT = 'district';
  104.     const RESULT_SOURCE_STATION = 'station';
  105.     const RESULT_SOURCE_APPROVED = 'approved';
  106.     const RESULT_SOURCE_WITH_COMMENTS = 'with_comments';
  107.     const RESULT_SOURCE_WITH_VIDEO = 'with_video';
  108.     const RESULT_SOURCE_WITH_SELFIE = 'with_selfie';
  109.     const RESULT_SOURCE_TOP_100 = 'top_100';
  110.     const RESULT_SOURCE_ELITE = 'elite';
  111.     const RESULT_SOURCE_MASSEURS = 'masseurs';
  112.     const RESULT_SOURCE_MASSAGE_SERVICE = 'massage_service';
  113.     const RESULT_SOURCE_BY_PARAMS = 'by_params';
  114.     const RESULT_SOURCE_SERVICE = 'service';
  115.     const RESULT_SOURCE_PROFILE_INVENTORY_ITEM = 'profile_inventory_item';
  116.     const RESULT_SOURCE_CITY = 'city';
  117.     const RESULT_SOURCE_COUNTRY = 'country';
  118.     const RESULT_SOURCE_WITH_WHATSAPP = 'with_whatsapp';
  119.     const RESULT_SOURCE_WITH_TELEGRAM = 'with_telegram';
  120.     const RESULT_SOURCE_WITH_MAX = 'with_max';
  121.     const RESULT_SOURCE_EIGHTEEN_YEARS_OLD = 'eighteen_years_old';
  122.     const RESULT_SOURCE_BIG_ASS = 'big_ass';
  123.     const RESULT_SOURCE_WITH_TATTOO = 'with_tattoo';
  124.     const RESULT_SOURCE_WITH_PIERCING = 'with_piercing';
  125.     const RESULT_SOURCE_ROUND_THE_CLOCK = 'round_the_clock';
  126.     const RESULT_SOURCE_FOR_TWO_HOURS = 'for_two_hours';
  127.     const RESULT_SOURCE_FOR_HOUR = 'for_hour';
  128.     const RESULT_SOURCE_EXPRESS_PROGRAM = 'express_program';
  129.     const RESULT_SOURCE_EROMASSAGE = 'eromassage';
  130.     const RESULT_SOURCE_VERIFIED = 'verified';
  131.     const RESULT_SOURCE_CHEAP = 'cheap';
  132.     const RESULT_SOURCE_MATURE = 'mature';
  133.     const RESULT_SOURCE_UZBEK = 'uzbek';
  134.     const RESULT_SOURCE_INDI_MAIN = 'indi_main';
  135.     const RESULT_SOURCE_INDI_CHECKED = 'indi_checked';
  136.     const RESULT_SOURCE_INDI_MATURE = 'indi_mature';
  137.     const RESULT_SOURCE_INDI_CHEAP = 'indi_cheap';
  138.     const RESULT_SOURCE_INDI_WITH_COMMENTS = 'indi_with_comments';
  139.     private ?string $source = null;
  140.     public function __construct(
  141.         private RequestStack $requestStack,
  142.         private ProfileList                     $profileList,
  143.         private CountryCurrencyResolver         $countryCurrencyResolver,
  144.         private ServiceRepository               $serviceRepository,
  145.         private ListingService                  $listingService,
  146.         private Features                        $features,
  147.         private ProfileFilterService            $profilesFilterService,
  148.         private ProfileListSpecificationService $profileListSpecificationService,
  149.         private ProfileListingDataCreator       $profileListingDataCreator,
  150.         private Top100ProfilesService           $top100ProfilesService,
  151.         private CacheItemPoolInterface          $stationAddedProfilesCache,
  152.         private ParameterBagInterface           $parameterBag,
  153.         private ListingRotationApi              $listingRotationApi,
  154.         private ProfileTopBoard                 $profileTopBoard,
  155.         private HomepageCityListingsBlockProvider $homepageCityListingsBlockProvider,
  156.         private ProfileListingRecommendationsFiller $profileListingRecommendationsFiller,
  157.         private ProfileListingAppliedFiltersResolver $listingAppliedFiltersResolver,
  158.         private NormalizerInterface $normalizer,
  159.         private ProfileNameLandingProvider $profileNameLandingProvider,
  160.         private GeoCategoryLinkageService $geoCategoryLinkageService,
  161.         private MixedCityListings $mixedCityListings,
  162.     ) {}
  163.     /**
  164.      * @param Page|array $result
  165.      */
  166.     protected function jsonListingResponse($result, City $city, ?ProfileListSpecification $specs = null, array $extra = []): JsonResponse
  167.     {
  168.         $filters = $this->listingAppliedFiltersResolver->resolve($city, $specs);
  169.         $extra = array_merge(['linkage' => $this->geoCategoryLinkageService->links($city) ?? []], $extra);
  170.         if (is_array($result)) {
  171.             return $this->json(array_merge(['filters' => $filters], $result, $extra));
  172.         }
  173.         $normalized = $this->normalizer->normalize($result);
  174.         if (!is_array($normalized)) {
  175.             $normalized = ['data' => $normalized];
  176.         }
  177.         return $this->json(array_merge(['filters' => $filters], $normalized, $extra));
  178.     }
  179.     /**
  180.      * @Feature("has_masseurs")
  181.      */
  182.     #[ParamConverter("city", converter: "city_converter")]
  183.     #[Route("/api/profiles/listing/city/{city}/masseur", name: "api.profile_listing.masseur", methods: "GET", format: "json")]
  184.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  185.     #[OA\Tag(name: "ProfileListing")]
  186.     #[OA\Response(
  187.         response: 200,
  188.         description: '',
  189.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  190.     )]
  191.     public function listForMasseur(Request $request, City $city, ServiceRepository $serviceRepository): Response
  192.     {
  193.         $specs = $this->profileListSpecificationService->listForMasseur($city);
  194.         $response = new Response();
  195.         $massageGroupServices = $serviceRepository->findBy(['group' => ServiceGroups::MASSAGE]);
  196.         $alternativeSpec = $this->getORSpecForItemsArray([$massageGroupServices], function($item): ProfileIsProvidingOneOfServices {
  197.             return new ProfileIsProvidingOneOfServices($item);
  198.         });
  199.         $result = $this->paginatedListing($city, '/city/{city}/masseur', ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_MASSAGE_SERVICE, $response, masseur: null);
  200.         if ($this->isApiRequest($request)) {
  201.             return $this->jsonListingResponse($result, $city, $specs);
  202.         }
  203.         return $this->render('ProfileList/list.html.twig', [
  204.             'profiles' => $result,
  205.             'source' => $this->source,
  206.             'source_default' => self::RESULT_SOURCE_MASSEURS,
  207.             'recommendationSpec' => $specs->recommendationSpec(),
  208.         ], response: $response);
  209.     }
  210.     /**
  211.      * @Feature("extra_category_big_ass")
  212.      */
  213.     #[ParamConverter("city", converter: "city_converter")]
  214.     #[Route("/api/profiles/listing/city/{city}/category/big_ass", name: "api.profile_listing.category.big_ass", methods: "GET", format: "json")]
  215.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  216.     #[OA\Tag(name: "ProfileListing")]
  217.     #[OA\Response(
  218.         response: 200,
  219.         description: '',
  220.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  221.     )]
  222.     public function listBigAss(Request $request, City $city): Response
  223.     {
  224.         $specs = $this->profileListSpecificationService->listBigAss();
  225.         $response = new Response();
  226.         $result = $this->paginatedListing($city, '/city/{city}/category/big_ass', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  227.         if ($this->isApiRequest($request)) {
  228.             return $this->jsonListingResponse($result, $city, $specs);
  229.         }
  230.         return $this->render('ProfileList/list.html.twig', [
  231.             'profiles' => $result,
  232.             'source' => $this->source,
  233.             'source_default' => self::RESULT_SOURCE_BIG_ASS,
  234.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  235.                 'city' => $city->getUriIdentity(),
  236.                 'page' => $this->getCurrentPageNumber(),
  237.             ]),
  238.             'recommendationSpec' => $specs->recommendationSpec(),
  239.         ], response: $response);
  240.     }
  241.     public function listByDefaultCity(ParameterBagInterface $parameterBag, Request $request): Response
  242.     {
  243.         $controller = get_class($this).'::listByCity';
  244.         $path = [
  245.             'city' => $parameterBag->get('default_city'),
  246.             'subRequest' => true,
  247.         ];
  248.         //чтобы в обработчике можно было понять, по какому роуту зашли
  249.         $request->request->set('_route', 'profile_list.list_by_city');
  250.         return $this->forward($controller, $path);
  251.     }
  252.     public function profileLandingListing(
  253.         Request $request,
  254.         City $city,
  255.         ProfileListSpecification $specs,
  256.         string $source,
  257.         ?string $apiEndpoint = null,
  258.         ?bool $masseur = false,
  259.     ): Response {
  260.         $response = new Response();
  261.         $result = $this->paginatedListing(
  262.             $city,
  263.             $apiEndpoint,
  264.             ['city' => $city->getId()],
  265.             $specs->spec(),
  266.             null,
  267.             null,
  268.             $response,
  269.             masseur: $masseur
  270.         );
  271.         if ($this->isApiRequest($request)) {
  272.             return $this->jsonListingResponse($result, $city, $specs);
  273.         }
  274.         $request->attributes->set('profiles_count', $result->totalCount());
  275.         $request->attributes->set('listingTypeName', $source);
  276.         $request->attributes->set('city', $city);
  277.         return $this->render('ProfileList/list.html.twig', [
  278.             'profiles' => $result,
  279.             'source' => $this->source,
  280.             'source_default' => $source,
  281.             'listing' => $source,
  282.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  283.                 'city' => $city->getUriIdentity(),
  284.                 'page' => $this->getCurrentPageNumber(),
  285.             ]),
  286.             'recommendationSpec' => $specs->recommendationSpec(),
  287.         ], response: $response);
  288.     }
  289.     private function paginatedListing(
  290.         City $city,
  291.         ?string $apiEndpoint,
  292.         array $apiParams,
  293.         ?Filter $listingSpec = null,
  294.         ?OrX $alternativeSpec = null,
  295.         ?string $alternativeSource = null,
  296.         ?Response $response = null,
  297.         bool $fallbackWithinCity = true,
  298.         ?bool $masseur = null,
  299.         bool $forceDoctrineFallback = false,
  300.     ): Page
  301.     {
  302.         $omitCity = $this->mixedCityListings->omitCityOnProfileFallback($apiEndpoint);
  303.         $topPlacement = null;
  304.         if (!$omitCity) {
  305.             $topPlacement = $this->profileTopBoard->topPlacementSatisfiedBy($city, $listingSpec);
  306.             $topPlacement?->setTopCard(); // mark as top card for UI
  307.         }
  308.         $page = $this->getCurrentPageNumber();
  309.         $apiParams['city'] = $city->getId();
  310.         try {
  311.             if (null === $apiEndpoint || $forceDoctrineFallback) {
  312.                 throw new \RuntimeException('Empty API endpoint to switch to legacy listing query.');
  313.             }
  314.             $result = $this->listingRotationApi->paginate($apiEndpoint, $apiParams, $page, $topPlacement);
  315.             $response?->setMaxAge(10);
  316.         } catch (\Exception) {
  317.             if ($fallbackWithinCity) {
  318.                 $avoidOrTopPlacement = (!$omitCity && null !== $topPlacement && $page < 2) ? $topPlacement : null;
  319.                 $result = $this->profileList->list($city, null, $listingSpec, [], true, $masseur, ProfileList::ORDER_BY_STATUS,
  320.                     null, true, null, [Genders::FEMALE], $avoidOrTopPlacement, withinCity: !$omitCity);
  321.             } else {
  322.                 $result = $this->profileList->listActiveOrderedByStatusWithSpec($listingSpec);
  323.             }
  324.         }
  325.         return $result;
  326.     }
  327.     #[SplitFirstPagePagination]
  328.     #[ParamConverter("city", converter: "city_converter")]
  329.     #[Route("/api/profiles/listing/city/{city}", name: "api.profile_listing.by_city", methods: "GET", format: "json")]
  330.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  331.     #[OA\Tag(name: "ProfileListing")]
  332.     #[OA\Response(
  333.         response: 200,
  334.         description: 'Листинг анкет по городу',
  335.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  336.     )]
  337.     public function listByCity(ParameterBagInterface $parameterBag, Request $request, City $city, bool $subRequest = false): Response
  338.     {
  339.         $page = $this->getCurrentPageNumber();
  340.         if (!$this->isApiRequest($request) && $this->features->redirect_default_city_to_homepage() && false === $subRequest && $city->equals($parameterBag->get('default_city')) && $page < 2) {
  341.             return $this->redirectToRoute('homepage', [], 301);
  342.         }
  343.         $specs = $this->profileListSpecificationService->listByCity();
  344.         $response = new Response();
  345.         $result = $this->paginatedListing($city, '/city/{city}', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  346.         if ($this->isApiRequest($request)) {
  347.             return $this->jsonListingResponse($result, $city, $specs);
  348.         }
  349.         $homepageCityListingsBlock = null;
  350.         if ($this->shouldShowHomepageCityListingsBlock($city, $page, $subRequest)) {
  351.             $homepageCityListingsBlock = $this->homepageCityListingsBlockProvider->getForCity($city);
  352.         }
  353.         return $this->render('ProfileList/list.html.twig', [
  354.             'profiles' => $result,
  355.             'homepage_city_listings_block' => $homepageCityListingsBlock,
  356.             'recommendationSpec' => $specs->recommendationSpec(),
  357.         ], response: $response);
  358.     }
  359.     /**
  360.      * @Feature("indi_main")
  361.      */
  362.     #[ParamConverter("city", converter: "city_converter")]
  363.     #[Route("/api/profiles/listing/city/{city}/category/individualki", name: "api.profile_listing.category.individualki", methods: "GET", format: "json")]
  364.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  365.     #[OA\Tag(name: "ProfileListing")]
  366.     #[OA\Response(
  367.         response: 200,
  368.         description: '',
  369.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  370.     )]
  371.     public function listIndiMain(Request $request, City $city): Response
  372.     {
  373.         $specs = $this->profileListSpecificationService->listIndiMain($city);
  374.         $response = new Response();
  375.         $result = $this->paginatedListing(
  376.             $city,
  377.             '/city/{city}/category/individualki',
  378.             ['city' => $city->getId()],
  379.             $specs->spec(),
  380.             null,
  381.             null,
  382.             $response,
  383.             forceDoctrineFallback: true,
  384.         );
  385.         if ($this->isApiRequest($request)) {
  386.             return $this->jsonListingResponse($result, $city, $specs);
  387.         }
  388.         $request->attributes->set('profiles_count', $result->totalCount());
  389.         $request->attributes->set('listingTypeName', self::RESULT_SOURCE_INDI_MAIN);
  390.         $request->attributes->set('city', $city);
  391.         return $this->render('ProfileList/list.html.twig', [
  392.             'profiles' => $result,
  393.             'source' => $this->source,
  394.             'source_default' => self::RESULT_SOURCE_INDI_MAIN,
  395.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  396.                 'city' => $city->getUriIdentity(),
  397.                 'page' => $this->getCurrentPageNumber(),
  398.             ]),
  399.             'recommendationSpec' => $specs->recommendationSpec(),
  400.         ], response: $response);
  401.     }
  402.     /** @Feature("indi_checked") */
  403.     #[ParamConverter("city", converter: "city_converter")]
  404.     #[Route("/api/profiles/listing/city/{city}/category/individualki/verified", name: "api.profile_listing.individual.verified", methods: "GET", format: "json")]
  405.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  406.     #[OA\Tag(name: "ProfileListing")]
  407.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  408.     public function listIndiChecked(Request $request, City $city): Response
  409.     {
  410.         return $this->profileLandingListing($request, $city, $this->profileListSpecificationService->listIndiChecked($city), self::RESULT_SOURCE_INDI_CHECKED);
  411.     }
  412.     /** @Feature("indi_mature") */
  413.     #[ParamConverter("city", converter: "city_converter")]
  414.     #[Route("/api/profiles/listing/city/{city}/category/individualki/mature", name: "api.profile_listing.individual.mature", methods: "GET", format: "json")]
  415.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  416.     #[OA\Tag(name: "ProfileListing")]
  417.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  418.     public function listIndiMature(Request $request, City $city): Response
  419.     {
  420.         return $this->profileLandingListing($request, $city, $this->profileListSpecificationService->listIndiMature($city), self::RESULT_SOURCE_INDI_MATURE);
  421.     }
  422.     /** @Feature("indi_cheap") */
  423.     #[ParamConverter("city", converter: "city_converter")]
  424.     #[Route("/api/profiles/listing/city/{city}/category/individualki/price-low", name: "api.profile_listing.individual.price_low", methods: "GET", format: "json")]
  425.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  426.     #[OA\Tag(name: "ProfileListing")]
  427.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  428.     public function listIndiCheap(Request $request, City $city): Response
  429.     {
  430.         return $this->profileLandingListing($request, $city, $this->profileListSpecificationService->listIndiCheap($city), self::RESULT_SOURCE_INDI_CHEAP);
  431.     }
  432.     /** @Feature("indi_with_comments") */
  433.     #[ParamConverter("city", converter: "city_converter")]
  434.     #[Route("/api/profiles/listing/city/{city}/category/individualki/comments", name: "api.profile_listing.individual.comments", methods: "GET", format: "json")]
  435.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  436.     #[OA\Tag(name: "ProfileListing")]
  437.     #[OA\Response(response: 200, description: '', content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage"))]
  438.     public function listIndiWithComments(Request $request, City $city): Response
  439.     {
  440.         return $this->profileLandingListing($request, $city, $this->profileListSpecificationService->listIndiWithComments($city), self::RESULT_SOURCE_INDI_WITH_COMMENTS);
  441.     }
  442.     /**
  443.      * @Feature("intim_moscow_listing")
  444.      */
  445.     #[Cache(maxage: 3600, public: true)]
  446.     #[ParamConverter("city", converter: "city_converter")]
  447.     #[Route("/api/profiles/listing/city/{city}/intim", name: "api.profile_listing.intim", methods: "GET", format: "json")]
  448.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  449.     #[OA\Tag(name: "ProfileListing")]
  450.     #[OA\Response(
  451.         response: 200,
  452.         description: '',
  453.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  454.     )]
  455.     public function listIntim(Request $request, City $city): Response
  456.     {
  457.         $specs = $this->profileListSpecificationService->listByCity();
  458.         $response = new Response();
  459.         $result = $this->paginatedListing($city, '/city/{city}/intim', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  460.         $result = $this->shuffleProfilesOnPage($result);
  461.         $response->setMaxAge(3600);
  462.         if ($this->isApiRequest($request)) {
  463.             return $this->jsonListingResponse($result, $city, $specs);
  464.         }
  465.         return $this->render('ProfileList/list.html.twig', [
  466.             'profiles' => $result,
  467.             'city' => $city,
  468.             'recommendationSpec' => $specs->recommendationSpec(),
  469.         ], response: $response);
  470.     }
  471.     #[ParamConverter("city", converter: "city_converter")]
  472.     #[Entity("county", expr: "repository.ofUriIdentityWithinCity(county, city)")]
  473.     #[Route("/api/profiles/listing/city/{city}/county/{county}", name: "api.profile_listing.by_county", methods: "GET", format: "json")]
  474.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  475.     #[OA\Tag(name: "ProfileListing")]
  476.     #[OA\Response(
  477.         response: 200,
  478.         description: '',
  479.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  480.     )]
  481.     public function listByCounty(Request $request, City $city, County $county): Response
  482.     {
  483.         if (!$city->hasCounty($county)) {
  484.             throw $this->createNotFoundException();
  485.         }
  486.         $specs = $this->profileListSpecificationService->listByCounty($county);
  487.         $response = new Response();
  488.         $alternativeSpec = Spec::orX(ProfileIsLocated::withinCounties($city, $city->getCounties()->toArray()));
  489.         $result = $this->paginatedListing($city, '/city/{city}/county/{county}', ['city' => $city->getId(), 'county' => $county->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_COUNTY, $response);
  490.         if ($this->isApiRequest($request)) {
  491.             return $this->jsonListingResponse($result, $city, $specs);
  492.         }
  493.         return $this->render('ProfileList/list.html.twig', [
  494.             'profiles' => $result,
  495.             'source' => $this->source,
  496.             'source_default' => self::RESULT_SOURCE_COUNTY,
  497.             'county' => $county,
  498.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  499.                 'city' => $city->getUriIdentity(),
  500.                 'county' => $county->getUriIdentity(),
  501.                 'page' => $this->getCurrentPageNumber()
  502.             ]),
  503.             'recommendationSpec' => $specs->recommendationSpec(),
  504.         ], response: $response);
  505.     }
  506.     #[ParamConverter("city", converter: "city_converter")]
  507.     #[Entity("district", expr: "repository.ofUriIdentityWithinCity(district, city)")]
  508.     #[Route("/api/profiles/listing/city/{city}/district/{district}", name: "api.profile_listing.by_district", methods: "GET", format: "json")]
  509.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  510.     #[OA\Tag(name: "ProfileListing")]
  511.     #[OA\Response(
  512.         response: 200,
  513.         description: '',
  514.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  515.     )]
  516.     public function listByDistrict(Request $request, City $city, District $district): Response
  517.     {
  518.         if (!$city->hasDistrict($district)) {
  519.             throw $this->createNotFoundException();
  520.         }
  521.         $specs = $this->profileListSpecificationService->listByDistrict($district);
  522.         $response = new Response();
  523.         $alternativeSpec = Spec::orX(ProfileIsLocated::withinDistricts($city, $city->getDistricts()->toArray()));
  524.         $result = $this->paginatedListing($city, '/city/{city}/district/{district}', ['city' => $city->getId(), 'district' => $district->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_DISTRICT, $response);
  525.         if ($this->isApiRequest($request)) {
  526.             return $this->jsonListingResponse($result, $city, $specs);
  527.         }
  528.         return $this->render('ProfileList/list.html.twig', [
  529.             'profiles' => $result,
  530.             'source' => $this->source,
  531.             'source_default' => self::RESULT_SOURCE_DISTRICT,
  532.             'district' => $district,
  533.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  534.                 'city' => $city->getUriIdentity(),
  535.                 'district' => $district->getUriIdentity(),
  536.                 'page' => $this->getCurrentPageNumber()
  537.             ]),
  538.             'recommendationSpec' => $specs->recommendationSpec(),
  539.         ], response: $response);
  540.     }
  541.     /**
  542.      * @Feature("extra_category_without_prepayment")
  543.      */
  544.     #[ParamConverter("city", converter: "city_converter")]
  545.     #[Route("/api/profiles/listing/city/{city}/category/without_prepayment", name: "api.profile_listing.category.without_prepayment", methods: "GET", format: "json")]
  546.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  547.     #[OA\Tag(name: "ProfileListing")]
  548.     #[OA\Response(
  549.         response: 200,
  550.         description: '',
  551.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  552.     )]
  553.     public function listWithoutPrepayment(Request $request, City $city): Response
  554.     {
  555.         $listingData = $this->profileListingDataCreator->getListingDataForFilter('listWithoutPrepayment', [], $city);
  556.         $specs = $listingData['specs'];
  557.         $listingTypeName = $listingData['listingTypeName'];
  558.         $response = new Response();
  559.         $result = $this->paginatedListing($city, '/city/{city}/category/without_prepayment', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  560.         if ($this->isApiRequest($request)) {
  561.             return $this->jsonListingResponse($result, $city, $specs);
  562.         }
  563.         $request->attributes->set('profiles_count', $result->totalCount());
  564.         $request->attributes->set('listingTypeName', $listingTypeName);
  565.         $request->attributes->set('city', $city);
  566.         return $this->render('ProfileList/list.html.twig', [
  567.             'profiles' => $result,
  568.             'source' => $this->source,
  569.             'source_default' => 'without_prepayment',
  570.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  571.                 'city' => $city->getUriIdentity(),
  572.                 'page' => $this->getCurrentPageNumber(),
  573.             ]),
  574.             'recommendationSpec' => $specs->recommendationSpec(),
  575.         ], response: $response);
  576.     }
  577.     #[ParamConverter("city", converter: "city_converter")]
  578.     #[Entity("station", expr: "repository.ofUriIdentityWithinCity(station, city)")]
  579.     #[Route("/api/profiles/listing/city/{city}/station/{station}", name: "api.profile_listing.by_station", methods: "GET", format: "json")]
  580.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  581.     #[OA\Tag(name: "ProfileListing")]
  582.     #[OA\Response(
  583.         response: 200,
  584.         description: '',
  585.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  586.     )]
  587.     public function listByStation(Request $request, City $city, Station $station): Response
  588.     {
  589.         if (!$city->hasStation($station)) {
  590.             throw $this->createNotFoundException();
  591.         }
  592.         $specs = $this->profileListSpecificationService->listByStation($station);
  593.         $response = new Response();
  594.         $result = $this->paginatedListing($city, '/city/{city}/station/{station}', ['city' => $city->getId(), 'station' => $station->getId()], $specs->spec(), null, null, $response);
  595.         if ($this->isApiRequest($request)) {
  596.             return $this->jsonListingResponse($result, $city, $specs);
  597.         }
  598.         return $this->render('ProfileList/list.html.twig', [
  599.             'profiles' => $result,
  600.             'source' => $this->source,
  601.             'source_default' => self::RESULT_SOURCE_STATION,
  602.             'station' => $station,
  603.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  604.                 'city' => $city->getUriIdentity(),
  605.                 'station' => $station->getUriIdentity(),
  606.                 'page' => $this->getCurrentPageNumber()
  607.             ]),
  608.             'recommendationSpec' => $specs->recommendationSpec(),
  609.         ], response: $response);
  610.     }
  611.     #[ParamConverter("city", converter: "city_converter")]
  612.     public function listByStations(City $city, string $stations, StationRepository $stationRepository): Response
  613.     {
  614.         $stationIds = explode(',', $stations);
  615.         $stations = $stationRepository->findBy(['uriIdentity' => $stationIds]);
  616.         $specs = $this->profileListSpecificationService->listByStations($stations);
  617.         $response = new Response();
  618.         $result = $this->paginatedListing($city, null, [], $specs->spec(), null, null, $response);
  619.         return $this->render('ProfileList/list.html.twig', [
  620.             'profiles' => $result,
  621.             'recommendationSpec' => $specs->recommendationSpec(),
  622.         ]);
  623.     }
  624.     #[ParamConverter("city", converter: "city_converter")]
  625.     #[Route("/api/profiles/listing/city/{city}/approved", name: "api.profile_listing.approved", methods: "GET", format: "json")]
  626.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  627.     #[OA\Tag(name: "ProfileListing")]
  628.     #[OA\Response(
  629.         response: 200,
  630.         description: '',
  631.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  632.     )]
  633.     public function listApproved(Request $request, City $city): Response
  634.     {
  635.         $specs = $this->profileListSpecificationService->listApproved();
  636.         $response = new Response();
  637.         $result = $this->paginatedListing($city, '/city/{city}/approved', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  638.         if ($this->isApiRequest($request)) {
  639.             return $this->jsonListingResponse($result, $city, $specs);
  640.         }
  641.         return $this->render('ProfileList/list.html.twig', [
  642.             'profiles' => $result,
  643.             'source' => $this->source,
  644.             'source_default' => self::RESULT_SOURCE_APPROVED,
  645.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  646.                 'city' => $city->getUriIdentity(),
  647.                 'page' => $this->getCurrentPageNumber()
  648.             ]),
  649.             'recommendationSpec' => $specs->recommendationSpec(),
  650.         ], response: $response);
  651.     }
  652.     /**
  653.      * @Feature("extra_category_with_whatsapp")
  654.      */
  655.     #[ParamConverter("city", converter: "city_converter")]
  656.     #[Route("/api/profiles/listing/city/{city}/category/whatsapp", name: "api.profile_listing.category.whatsapp", methods: "GET", format: "json")]
  657.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  658.     #[OA\Tag(name: "ProfileListing")]
  659.     #[OA\Response(
  660.         response: 200,
  661.         description: '',
  662.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  663.     )]
  664.     public function listWithWhatsapp(Request $request, City $city): Response
  665.     {
  666.         $specs = $this->profileListSpecificationService->listWithWhatsapp();
  667.         $response = new Response();
  668.         $result = $this->paginatedListing($city, '/city/{city}/category/whatsapp', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  669.         if ($this->isApiRequest($request)) {
  670.             return $this->jsonListingResponse($result, $city, $specs);
  671.         }
  672.         return $this->render('ProfileList/list.html.twig', [
  673.             'profiles' => $result,
  674.             'source' => $this->source,
  675.             'source_default' => self::RESULT_SOURCE_WITH_WHATSAPP,
  676.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  677.                 'city' => $city->getUriIdentity(),
  678.                 'page' => $this->getCurrentPageNumber(),
  679.             ]),
  680.             'recommendationSpec' => $specs->recommendationSpec(),
  681.         ], response: $response);
  682.     }
  683.     /**
  684.      * @Feature("extra_category_with_telegram")
  685.      */
  686.     #[ParamConverter("city", converter: "city_converter")]
  687.     #[Route("/api/profiles/listing/city/{city}/category/telegram", name: "api.profile_listing.category.telegram", methods: "GET", format: "json")]
  688.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  689.     #[OA\Tag(name: "ProfileListing")]
  690.     #[OA\Response(
  691.         response: 200,
  692.         description: '',
  693.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  694.     )]
  695.     public function listWithTelegram(Request $request, City $city): Response
  696.     {
  697.         $specs = $this->profileListSpecificationService->listWithTelegram();
  698.         $response = new Response();
  699.         $result = $this->paginatedListing($city, '/city/{city}/category/telegram', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  700.         if ($this->isApiRequest($request)) {
  701.             return $this->jsonListingResponse($result, $city, $specs);
  702.         }
  703.         return $this->render('ProfileList/list.html.twig', [
  704.             'profiles' => $result,
  705.             'source' => $this->source,
  706.             'source_default' => self::RESULT_SOURCE_WITH_TELEGRAM,
  707.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  708.                 'city' => $city->getUriIdentity(),
  709.                 'page' => $this->getCurrentPageNumber(),
  710.             ]),
  711.             'recommendationSpec' => $specs->recommendationSpec(),
  712.         ], response: $response);
  713.     }
  714.     /**
  715.      * @Feature("extra_category_with_max")
  716.      */
  717.     #[ParamConverter("city", converter: "city_converter")]
  718.     #[Route("/api/profiles/listing/city/{city}/category/max", name: "api.profile_listing.category.max", methods: "GET", format: "json")]
  719.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  720.     #[OA\Tag(name: "ProfileListing")]
  721.     #[OA\Response(
  722.         response: 200,
  723.         description: '',
  724.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  725.     )]
  726.     public function listWithMax(Request $request, City $city): Response
  727.     {
  728.         $specs = $this->profileListSpecificationService->listWithMax();
  729.         $response = new Response();
  730.         $result = $this->paginatedListing($city, '/city/{city}/category/max', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  731.         if ($this->isApiRequest($request)) {
  732.             return $this->jsonListingResponse($result, $city, $specs);
  733.         }
  734.         return $this->render('ProfileList/list.html.twig', [
  735.             'profiles' => $result,
  736.             'source' => $this->source,
  737.             'source_default' => self::RESULT_SOURCE_WITH_MAX,
  738.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  739.                 'city' => $city->getUriIdentity(),
  740.                 'page' => $this->getCurrentPageNumber(),
  741.             ]),
  742.             'recommendationSpec' => $specs->recommendationSpec(),
  743.         ], response: $response);
  744.     }
  745.     /**
  746.      * @Feature("extra_category_eighteen_years_old")
  747.      */
  748.     #[ParamConverter("city", converter: "city_converter")]
  749.     #[Route("/api/profiles/listing/city/{city}/category/eighteen_years_old", name: "api.profile_listing.category.eighteen_years_old", methods: "GET", format: "json")]
  750.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  751.     #[OA\Tag(name: "ProfileListing")]
  752.     #[OA\Response(
  753.         response: 200,
  754.         description: '',
  755.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  756.     )]
  757.     public function listEighteenYearsOld(Request $request, City $city): Response
  758.     {
  759.         $specs = $this->profileListSpecificationService->listEighteenYearsOld();
  760.         $response = new Response();
  761.         $result = $this->paginatedListing($city, '/city/{city}/category/eighteen_years_old', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  762.         if ($this->isApiRequest($request)) {
  763.             return $this->jsonListingResponse($result, $city, $specs);
  764.         }
  765.         return $this->render('ProfileList/list.html.twig', [
  766.             'profiles' => $result,
  767.             'source' => $this->source,
  768.             'source_default' => self::RESULT_SOURCE_EIGHTEEN_YEARS_OLD,
  769.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  770.                 'city' => $city->getUriIdentity(),
  771.                 'page' => $this->getCurrentPageNumber(),
  772.             ]),
  773.             'recommendationSpec' => $specs->recommendationSpec(),
  774.         ], response: $response);
  775.     }
  776.     /**
  777.      * @Feature("extra_category_rublevskie")
  778.      */
  779.     #[ParamConverter("city", converter: "city_converter")]
  780.     #[Route("/api/profiles/listing/city/{city}/category/rublevskie", name: "api.profile_listing.category.rublevskie", methods: "GET", format: "json")]
  781.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  782.     #[OA\Tag(name: "ProfileListing")]
  783.     #[OA\Response(
  784.         response: 200,
  785.         description: '',
  786.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  787.     )]
  788.     public function listRublevskie(Request $request, City $city): Response
  789.     {
  790.         if ($city->getUriIdentity() !== 'moscow') {
  791.             throw $this->createNotFoundException();
  792.         }
  793.         $specs = $this->profileListSpecificationService->listRublevskie($city);
  794.         $response = new Response();
  795.         $result = $this->paginatedListing($city, '/city/{city}/category/rublevskie', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  796.         if ($this->isApiRequest($request)) {
  797.             return $this->jsonListingResponse($result, $city, $specs);
  798.         }
  799.         return $this->render('ProfileList/list.html.twig', [
  800.             'profiles' => $result,
  801.             'source' => $this->source,
  802.             'source_default' => 'rublevskie',
  803.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  804.                 'city' => $city->getUriIdentity(),
  805.                 'page' => $this->getCurrentPageNumber(),
  806.             ]),
  807.             'recommendationSpec' => $specs->recommendationSpec(),
  808.         ], response: $response);
  809.     }
  810.     /**
  811.      * @Feature("extra_category_with_tattoo")
  812.      */
  813.     #[ParamConverter("city", converter: "city_converter")]
  814.     #[Route("/api/profiles/listing/city/{city}/category/with_tattoo", name: "api.profile_listing.category.with_tattoo", methods: "GET", format: "json")]
  815.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  816.     #[OA\Tag(name: "ProfileListing")]
  817.     #[OA\Response(
  818.         response: 200,
  819.         description: '',
  820.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  821.     )]
  822.     public function listWithTattoo(Request $request, City $city): Response
  823.     {
  824.         $specs = $this->profileListSpecificationService->listWithTattoo();
  825.         $response = new Response();
  826.         $result = $this->paginatedListing($city, '/city/{city}/category/with_tattoo', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  827.         if ($this->isApiRequest($request)) {
  828.             return $this->jsonListingResponse($result, $city, $specs);
  829.         }
  830.         return $this->render('ProfileList/list.html.twig', [
  831.             'profiles' => $result,
  832.             'source' => $this->source,
  833.             'source_default' => self::RESULT_SOURCE_WITH_TATTOO,
  834.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  835.                 'city' => $city->getUriIdentity(),
  836.                 'page' => $this->getCurrentPageNumber(),
  837.             ]),
  838.             'recommendationSpec' => $specs->recommendationSpec(),
  839.         ], response: $response);
  840.     }
  841.     #[ParamConverter("city", converter: "city_converter")]
  842.     #[Route("/api/profiles/listing/city/{city}/with_comments", name: "api.profile_listing.with_comments", methods: "GET", format: "json")]
  843.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  844.     #[OA\Tag(name: "ProfileListing")]
  845.     #[OA\Response(
  846.         response: 200,
  847.         description: '',
  848.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  849.     )]
  850.     public function listWithComments(Request $request, City $city): Response
  851.     {
  852.         $specs = $this->profileListSpecificationService->listWithComments();
  853.         $response = new Response();
  854.         $result = $this->paginatedListing($city, '/city/{city}/with_comments', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  855.         if ($this->isApiRequest($request)) {
  856.             return $this->jsonListingResponse($result, $city, $specs);
  857.         }
  858.         return $this->render('ProfileList/list.html.twig', [
  859.             'profiles' => $result,
  860.             'source' => $this->source,
  861.             'source_default' => self::RESULT_SOURCE_WITH_COMMENTS,
  862.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  863.                 'city' => $city->getUriIdentity(),
  864.                 'page' => $this->getCurrentPageNumber()
  865.             ]),
  866.             'recommendationSpec' => $specs->recommendationSpec(),
  867.         ], response: $response);
  868.     }
  869.     /**
  870.      * @Feature("extra_category_with_piercing")
  871.      */
  872.     #[ParamConverter("city", converter: "city_converter")]
  873.     #[Route("/api/profiles/listing/city/{city}/category/with_piercing", name: "api.profile_listing.category.with_piercing", methods: "GET", format: "json")]
  874.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  875.     #[OA\Tag(name: "ProfileListing")]
  876.     #[OA\Response(
  877.         response: 200,
  878.         description: '',
  879.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  880.     )]
  881.     public function listWithPiercing(Request $request, City $city): Response
  882.     {
  883.         $specs = $this->profileListSpecificationService->listWithPiercing();
  884.         $response = new Response();
  885.         $result = $this->paginatedListing($city, '/city/{city}/category/with_piercing', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  886.         if ($this->isApiRequest($request)) {
  887.             return $this->jsonListingResponse($result, $city, $specs);
  888.         }
  889.         return $this->render('ProfileList/list.html.twig', [
  890.             'profiles' => $result,
  891.             'source' => $this->source,
  892.             'source_default' => self::RESULT_SOURCE_WITH_PIERCING,
  893.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  894.                 'city' => $city->getUriIdentity(),
  895.                 'page' => $this->getCurrentPageNumber(),
  896.             ]),
  897.             'recommendationSpec' => $specs->recommendationSpec(),
  898.         ], response: $response);
  899.     }
  900.     #[ParamConverter("city", converter: "city_converter")]
  901.     #[Route("/api/profiles/listing/city/{city}/with_video", name: "api.profile_listing.with_video", methods: "GET", format: "json")]
  902.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  903.     #[OA\Tag(name: "ProfileListing")]
  904.     #[OA\Response(
  905.         response: 200,
  906.         description: '',
  907.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  908.     )]
  909.     public function listWithVideo(Request $request, City $city): Response
  910.     {
  911.         $specs = $this->profileListSpecificationService->listWithVideo();
  912.         $response = new Response();
  913.         $result = $this->paginatedListing($city, '/city/{city}/with_video', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  914.         if ($this->isApiRequest($request)) {
  915.             return $this->jsonListingResponse($result, $city, $specs);
  916.         }
  917.         return $this->render('ProfileList/list.html.twig', [
  918.             'profiles' => $result,
  919.             'source' => $this->source,
  920.             'source_default' => self::RESULT_SOURCE_WITH_VIDEO,
  921.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  922.                 'city' => $city->getUriIdentity(),
  923.                 'page' => $this->getCurrentPageNumber()
  924.             ]),
  925.             'recommendationSpec' => $specs->recommendationSpec(),
  926.         ], response: $response);
  927.     }
  928.      /**
  929.      * @Feature("extra_category_round_the_clock")
  930.      */
  931.     #[ParamConverter("city", converter: "city_converter")]
  932.     #[Route("/api/profiles/listing/city/{city}/category/round_the_clock", name: "api.profile_listing.category.round_the_clock", methods: "GET", format: "json")]
  933.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  934.     #[OA\Tag(name: "ProfileListing")]
  935.     #[OA\Response(
  936.         response: 200,
  937.         description: '',
  938.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  939.     )]
  940.     public function listRoundTheClock(Request $request, City $city): Response
  941.     {
  942.         $specs = $this->profileListSpecificationService->listRoundTheClock();
  943.         $response = new Response();
  944.         $result = $this->paginatedListing($city, '/city/{city}/category/round_the_clock', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  945.         if ($this->isApiRequest($request)) {
  946.             return $this->jsonListingResponse($result, $city, $specs);
  947.         }
  948.         return $this->render('ProfileList/list.html.twig', [
  949.             'profiles' => $result,
  950.             'source' => $this->source,
  951.             'source_default' => self::RESULT_SOURCE_ROUND_THE_CLOCK,
  952.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  953.                 'city' => $city->getUriIdentity(),
  954.                 'page' => $this->getCurrentPageNumber(),
  955.             ]),
  956.             'recommendationSpec' => $specs->recommendationSpec(),
  957.         ], response: $response);
  958.     }
  959.     /**
  960.      * @Feature("extra_category_for_two_hours")
  961.      */
  962.     #[ParamConverter("city", converter: "city_converter")]
  963.     #[Route("/api/profiles/listing/city/{city}/category/for_two_hours", name: "api.profile_listing.category.for_two_hours", methods: "GET", format: "json")]
  964.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  965.     #[OA\Tag(name: "ProfileListing")]
  966.     #[OA\Response(
  967.         response: 200,
  968.         description: '',
  969.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  970.     )]
  971.     public function listForTwoHours(Request $request, City $city): Response
  972.     {
  973.         $specs = $this->profileListSpecificationService->listForTwoHours();
  974.         $response = new Response();
  975.         $result = $this->paginatedListing($city, '/city/{city}/category/for_two_hours', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  976.         if ($this->isApiRequest($request)) {
  977.             return $this->jsonListingResponse($result, $city, $specs);
  978.         }
  979.         return $this->render('ProfileList/list.html.twig', [
  980.             'profiles' => $result,
  981.             'source' => $this->source,
  982.             'source_default' => self::RESULT_SOURCE_FOR_TWO_HOURS,
  983.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  984.                 'city' => $city->getUriIdentity(),
  985.                 'page' => $this->getCurrentPageNumber(),
  986.             ]),
  987.             'recommendationSpec' => $specs->recommendationSpec(),
  988.         ], response: $response);
  989.     }
  990.     /**
  991.      * @Feature("extra_category_for_hour")
  992.      */
  993.     #[ParamConverter("city", converter: "city_converter")]
  994.     #[Route("/api/profiles/listing/city/{city}/category/for_hour", name: "api.profile_listing.category.for_hour", methods: "GET", format: "json")]
  995.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  996.     #[OA\Tag(name: "ProfileListing")]
  997.     #[OA\Response(
  998.         response: 200,
  999.         description: '',
  1000.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1001.     )]
  1002.     public function listForHour(Request $request, City $city): Response
  1003.     {
  1004.         $specs = $this->profileListSpecificationService->listForHour();
  1005.         $response = new Response();
  1006.         $result = $this->paginatedListing($city, '/city/{city}/category/for_hour', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1007.         if ($this->isApiRequest($request)) {
  1008.             return $this->jsonListingResponse($result, $city, $specs);
  1009.         }
  1010.         return $this->render('ProfileList/list.html.twig', [
  1011.             'profiles' => $result,
  1012.             'source' => $this->source,
  1013.             'source_default' => self::RESULT_SOURCE_FOR_HOUR,
  1014.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1015.                 'city' => $city->getUriIdentity(),
  1016.                 'page' => $this->getCurrentPageNumber(),
  1017.             ]),
  1018.             'recommendationSpec' => $specs->recommendationSpec(),
  1019.         ], response: $response);
  1020.     }
  1021.     /**
  1022.      * @Feature("extra_category_express_program")
  1023.      */
  1024.     #[ParamConverter("city", converter: "city_converter")]
  1025.     #[Route("/api/profiles/listing/city/{city}/category/express", name: "api.profile_listing.category.express", methods: "GET", format: "json")]
  1026.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1027.     #[OA\Tag(name: "ProfileListing")]
  1028.     #[OA\Response(
  1029.         response: 200,
  1030.         description: '',
  1031.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1032.     )]
  1033.     public function listExpress(Request $request, City $city): Response
  1034.     {
  1035.         $specs = $this->profileListSpecificationService->listExpress();
  1036.         $response = new Response();
  1037.         $result = $this->paginatedListing($city, '/city/{city}/category/express', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1038.         if ($this->isApiRequest($request)) {
  1039.             return $this->jsonListingResponse($result, $city, $specs);
  1040.         }
  1041.         return $this->render('ProfileList/list.html.twig', [
  1042.             'profiles' => $result,
  1043.             'source' => $this->source,
  1044.             'source_default' => self::RESULT_SOURCE_EXPRESS_PROGRAM,
  1045.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1046.                 'city' => $city->getUriIdentity(),
  1047.                 'page' => $this->getCurrentPageNumber(),
  1048.             ]),
  1049.             'recommendationSpec' => $specs->recommendationSpec(),
  1050.         ], response: $response);
  1051.     }
  1052.     /**
  1053.      * @Feature("extra_category_grandmothers")
  1054.      */
  1055.     #[ParamConverter("city", converter: "city_converter")]
  1056.     #[Route("/api/profiles/listing/city/{city}/category/grandmothers", name: "api.profile_listing.category.grandmothers", methods: "GET", format: "json")]
  1057.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1058.     #[OA\Tag(name: "ProfileListing")]
  1059.     #[OA\Response(
  1060.         response: 200,
  1061.         description: '',
  1062.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1063.     )]
  1064.     public function listGrandmothers(Request $request, City $city): Response
  1065.     {
  1066.         $specs = $this->profileListSpecificationService->listGrandmothers();
  1067.         $response = new Response();
  1068.         $result = $this->paginatedListing($city, '/city/{city}/category/grandmothers', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1069.         if ($this->isApiRequest($request)) {
  1070.             return $this->jsonListingResponse($result, $city, $specs);
  1071.         }
  1072.         return $this->render('ProfileList/list.html.twig', [
  1073.             'profiles' => $result,
  1074.             'source' => $this->source,
  1075.             'source_default' => 'grandmothers',
  1076.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1077.                 'city' => $city->getUriIdentity(),
  1078.                 'page' => $this->getCurrentPageNumber(),
  1079.             ]),
  1080.             'recommendationSpec' => $specs->recommendationSpec(),
  1081.         ], response: $response);
  1082.     }
  1083.         /**
  1084.      * @Feature("extra_category_big_breast")
  1085.      */
  1086.     #[ParamConverter("city", converter: "city_converter")]
  1087.     #[Route("/api/profiles/listing/city/{city}/category/big_breast", name: "api.profile_listing.category.big_breast", methods: "GET", format: "json")]
  1088.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1089.     #[OA\Tag(name: "ProfileListing")]
  1090.     #[OA\Response(
  1091.         response: 200,
  1092.         description: '',
  1093.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1094.     )]
  1095.     public function listBigBreast(Request $request, City $city): Response
  1096.     {
  1097.         $specs = $this->profileListSpecificationService->listBigBreast();
  1098.         $response = new Response();
  1099.         $result = $this->paginatedListing($city, '/city/{city}/category/big_breast', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1100.         if ($this->isApiRequest($request)) {
  1101.             return $this->jsonListingResponse($result, $city, $specs);
  1102.         }
  1103.         return $this->render('ProfileList/list.html.twig', [
  1104.             'profiles' => $result,
  1105.             'source' => $this->source,
  1106.             'source_default' => 'big_breast',
  1107.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1108.                 'city' => $city->getUriIdentity(),
  1109.                 'page' => $this->getCurrentPageNumber(),
  1110.             ]),
  1111.             'recommendationSpec' => $specs->recommendationSpec(),
  1112.         ], response: $response);
  1113.     }
  1114.     /**
  1115.      * @Feature("extra_category_very_skinny")
  1116.      */
  1117.     #[ParamConverter("city", converter: "city_converter")]
  1118.     #[Route("/api/profiles/listing/city/{city}/category/very_skinny", name: "api.profile_listing.category.very_skinny", methods: "GET", format: "json")]
  1119.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1120.     #[OA\Tag(name: "ProfileListing")]
  1121.     #[OA\Response(
  1122.         response: 200,
  1123.         description: '',
  1124.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1125.     )]
  1126.     public function listVerySkinny(Request $request, City $city): Response
  1127.     {
  1128.         $specs = $this->profileListSpecificationService->listVerySkinny();
  1129.         $response = new Response();
  1130.         $result = $this->paginatedListing($city, '/city/{city}/category/very_skinny', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1131.         if ($this->isApiRequest($request)) {
  1132.             return $this->jsonListingResponse($result, $city, $specs);
  1133.         }
  1134.         return $this->render('ProfileList/list.html.twig', [
  1135.             'profiles' => $result,
  1136.             'source' => $this->source,
  1137.             'source_default' => 'very_skinny',
  1138.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1139.                 'city' => $city->getUriIdentity(),
  1140.                 'page' => $this->getCurrentPageNumber(),
  1141.             ]),
  1142.             'recommendationSpec' => $specs->recommendationSpec(),
  1143.         ], response: $response);
  1144.     }
  1145.     /**
  1146.      * @Feature("extra_category_small_ass")
  1147.      */
  1148.     #[ParamConverter("city", converter: "city_converter")]
  1149.     #[Route("/api/profiles/listing/city/{city}/category/small_ass", name: "api.profile_listing.category.small_ass", methods: "GET", format: "json")]
  1150.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1151.     #[OA\Tag(name: "ProfileListing")]
  1152.     #[OA\Response(
  1153.         response: 200,
  1154.         description: '',
  1155.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1156.     )]
  1157.     public function listSmallAss(Request $request, City $city): Response
  1158.     {
  1159.         $specs = $this->profileListSpecificationService->listSmallAss();
  1160.         $response = new Response();
  1161.         $result = $this->paginatedListing($city, '/city/{city}/category/small_ass', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1162.         if ($this->isApiRequest($request)) {
  1163.             return $this->jsonListingResponse($result, $city, $specs);
  1164.         }
  1165.         return $this->render('ProfileList/list.html.twig', [
  1166.             'profiles' => $result,
  1167.             'source' => $this->source,
  1168.             'source_default' => 'small_ass',
  1169.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1170.                 'city' => $city->getUriIdentity(),
  1171.                 'page' => $this->getCurrentPageNumber(),
  1172.             ]),
  1173.             'recommendationSpec' => $specs->recommendationSpec(),
  1174.         ], response: $response);
  1175.     }
  1176.     /**
  1177.      * @Feature("extra_category_beautiful_prostitutes")
  1178.      */
  1179.     #[ParamConverter("city", converter: "city_converter")]
  1180.     #[Route("/api/profiles/listing/city/{city}/category/beautiful_prostitutes", name: "api.profile_listing.category.beautiful_prostitutes", methods: "GET", format: "json")]
  1181.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1182.     #[OA\Tag(name: "ProfileListing")]
  1183.     #[OA\Response(
  1184.         response: 200,
  1185.         description: '',
  1186.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1187.     )]
  1188.     public function listBeautifulProstitutes(Request $request, City $city): Response
  1189.     {
  1190.         $specs = $this->profileListSpecificationService->listBeautifulProstitutes();
  1191.         $response = new Response();
  1192.         $result = $this->paginatedListing($city, '/city/{city}/category/beautiful_prostitutes', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1193.         if ($this->isApiRequest($request)) {
  1194.             return $this->jsonListingResponse($result, $city, $specs);
  1195.         }
  1196.         return $this->render('ProfileList/list.html.twig', [
  1197.             'profiles' => $result,
  1198.             'source' => $this->source,
  1199.             'source_default' => 'beautiful_prostitutes',
  1200.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1201.                 'city' => $city->getUriIdentity(),
  1202.                 'page' => $this->getCurrentPageNumber(),
  1203.             ]),
  1204.             'recommendationSpec' => $specs->recommendationSpec(),
  1205.         ], response: $response);
  1206.     }
  1207.     /**
  1208.      * @Feature("extra_category_without_intermediaries")
  1209.      */
  1210.     #[ParamConverter("city", converter: "city_converter")]
  1211.     #[Route("/api/profiles/listing/city/{city}/category/without_intermediaries", name: "api.profile_listing.category.without_intermediaries", methods: "GET", format: "json")]
  1212.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1213.     #[OA\Tag(name: "ProfileListing")]
  1214.     #[OA\Response(
  1215.         response: 200,
  1216.         description: '',
  1217.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1218.     )]
  1219.     public function listWithoutIntermediaries(Request $request, City $city): Response
  1220.     {
  1221.         $specs = $this->profileListSpecificationService->listWithoutIntermediaries();
  1222.         $response = new Response();
  1223.         $result = $this->paginatedListing($city, '/city/{city}/category/without_intermediaries', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1224.         if ($this->isApiRequest($request)) {
  1225.             return $this->jsonListingResponse($result, $city, $specs);
  1226.         }
  1227.         return $this->render('ProfileList/list.html.twig', [
  1228.             'profiles' => $result,
  1229.             'source' => $this->source,
  1230.             'source_default' => 'without_intermediaries',
  1231.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1232.                 'city' => $city->getUriIdentity(),
  1233.                 'page' => $this->getCurrentPageNumber(),
  1234.             ]),
  1235.             'recommendationSpec' => $specs->recommendationSpec(),
  1236.         ], response: $response);
  1237.     }
  1238.     #[ParamConverter("city", converter: "city_converter")]
  1239.     #[Route("/api/profiles/listing/city/{city}/list-pages/suburbs", name: "api.profile_listing.list_pages.suburbs", methods: "GET", format: "json")]
  1240.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1241.     #[OA\Tag(name: "ProfileListing")]
  1242.     #[OA\Response(
  1243.         response: 200,
  1244.         description: 'Листинг анкет для страницы списка городов',
  1245.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1246.     )]
  1247.     public function listPageSuburbs(
  1248.         Request $request,
  1249.         City $city,
  1250.         CityRepository $cityRepository,
  1251.         ProfileRepository $profileRepository
  1252.     ): Response
  1253.     {
  1254.         $isApiRequest = $this->isApiRequest($request);
  1255.         $locale = $request->getLocale() ?? 'ru';
  1256.         $countries = Countries::getNames($locale);
  1257.         $countByCity = $profileRepository->countByCity();
  1258.         $profilesOnListPages = null;
  1259.         $specs = null;
  1260.         $response = new Response();
  1261.         $cities = [];
  1262.         foreach ($cityRepository->findAll() as $listCity) {
  1263.             $countryCode = $listCity->getCountryCode();
  1264.             $country = $countries[$countryCode];
  1265.             if (!isset($cities[$country])) {
  1266.                 $cities[$country] = [];
  1267.             }
  1268.             $route = $listCity->equals($city) ? 'homepage' : 'profile_list.list_by_city';
  1269.             $cities[$country][$listCity->getId()] = [
  1270.                 'city' => $listCity,
  1271.                 'count' => $countByCity[$listCity->getId()] ?? 0,
  1272.                 'uri' => $this->generateUrl($route, ['city' => $listCity->getUriIdentity()]),
  1273.             ];
  1274.         }
  1275.         if ($this->features->profiles_on_list_pages()) {
  1276.             $specs = $this->profileListSpecificationService->listPagesWithSuburbs($city);
  1277.             $profilesOnListPages = $this->paginatedListing(
  1278.                 $city,
  1279.                 '/city/{city}/list-pages/suburbs',
  1280.                 ['city' => $city->getId()],
  1281.                 $specs->spec(),
  1282.                 response: $response,
  1283.                 fallbackWithinCity: false
  1284.             );
  1285.         } elseif ($isApiRequest) {
  1286.             throw $this->createNotFoundException();
  1287.         }
  1288.         if ($isApiRequest) {
  1289.             return $this->jsonListingResponse($profilesOnListPages, $city, $specs);
  1290.         }
  1291.         return $this->render('CityList/list_by_country.html.twig', [
  1292.             'cities' => $cities,
  1293.             'profiles' => $profilesOnListPages,
  1294.             'profiles_on_list_pages' => $profilesOnListPages,
  1295.         ], response: $response);
  1296.     }
  1297.     #[ParamConverter("city", converter: "city_converter")]
  1298.     #[Route("/api/profiles/listing/city/{city}/list-pages/stations", name: "api.profile_listing.list_pages.stations", methods: "GET", format: "json")]
  1299.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1300.     #[OA\Tag(name: "ProfileListing")]
  1301.     #[OA\Response(
  1302.         response: 200,
  1303.         description: 'Листинг анкет для страницы списка метро',
  1304.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1305.     )]
  1306.     public function listPageStations(
  1307.         Request $request,
  1308.         City $city,
  1309.         EntitySortService $sortService,
  1310.         LocationsProfileCounters $locationsProfileCounters
  1311.     ): Response
  1312.     {
  1313.         $isApiRequest = $this->isApiRequest($request);
  1314.         $countByStations = $locationsProfileCounters->getCountByStations();
  1315.         $profilesOnListPages = null;
  1316.         $specs = null;
  1317.         $response = new Response();
  1318.         if ($this->features->profiles_on_list_pages()) {
  1319.             $specs = $this->profileListSpecificationService->listPagesWithStations();
  1320.             $profilesOnListPages = $this->paginatedListing(
  1321.                 $city,
  1322.                 '/city/{city}/list-pages/stations',
  1323.                 ['city' => $city->getId()],
  1324.                 $specs->spec(),
  1325.                 response: $response,
  1326.                 fallbackWithinCity: false
  1327.             );
  1328.         } elseif ($isApiRequest) {
  1329.             throw $this->createNotFoundException();
  1330.         }
  1331.         if ($isApiRequest) {
  1332.             return $this->jsonListingResponse($profilesOnListPages, $city, $specs);
  1333.         }
  1334.         return $this->render('StationList/list.html.twig', [
  1335.             'city' => $city,
  1336.             'stations' => $sortService->sortEntityArrayByTranslatableFieldName($city->getStations()->toArray(), 'name'),
  1337.             'count_by_stations' => $countByStations,
  1338.             'profiles' => $profilesOnListPages,
  1339.             'profiles_on_list_pages' => $profilesOnListPages,
  1340.         ], response: $response);
  1341.     }
  1342.     #[ParamConverter("city", converter: "city_converter")]
  1343.     #[Route("/api/profiles/listing/city/{city}/list-pages/districts", name: "api.profile_listing.list_pages.districts", methods: "GET", format: "json")]
  1344.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1345.     #[OA\Tag(name: "ProfileListing")]
  1346.     #[OA\Response(
  1347.         response: 200,
  1348.         description: 'Листинг анкет для страницы списка районов',
  1349.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1350.     )]
  1351.     public function listPageDistricts(
  1352.         Request $request,
  1353.         City $city,
  1354.         LocationsProfileCounters $locationsProfileCounters
  1355.     ): Response
  1356.     {
  1357.         $isApiRequest = $this->isApiRequest($request);
  1358.         if (count($city->getDistricts()) < 1) {
  1359.             if ($isApiRequest) {
  1360.                 throw $this->createNotFoundException();
  1361.             }
  1362.             return $this->redirectToRoute('profile_list.list_by_city', ['city' => $city->getUriIdentity()]);
  1363.         }
  1364.         $countByDistricts = $locationsProfileCounters->getCountByDistricts();
  1365.         $countByCounties = $locationsProfileCounters->getCountByCounties();
  1366.         $profilesOnListPages = null;
  1367.         $specs = null;
  1368.         $response = new Response();
  1369.         if ($this->features->profiles_on_list_pages()) {
  1370.             $specs = $this->profileListSpecificationService->listPagesWithDistricts();
  1371.             $profilesOnListPages = $this->paginatedListing(
  1372.                 $city,
  1373.                 '/city/{city}/list-pages/districts',
  1374.                 ['city' => $city->getId()],
  1375.                 $specs->spec(),
  1376.                 response: $response,
  1377.                 fallbackWithinCity: false
  1378.             );
  1379.         } elseif ($isApiRequest) {
  1380.             throw $this->createNotFoundException();
  1381.         }
  1382.         if ($isApiRequest) {
  1383.             return $this->jsonListingResponse($profilesOnListPages, $city, $specs);
  1384.         }
  1385.         return $this->render('DistrictList/list.html.twig', [
  1386.             'city' => $city,
  1387.             'count_by_districts' => $countByDistricts,
  1388.             'count_by_counties' => $countByCounties,
  1389.             'profiles' => $profilesOnListPages,
  1390.             'profiles_on_list_pages' => $profilesOnListPages,
  1391.         ], response: $response);
  1392.     }
  1393.     #[ParamConverter("city", converter: "city_converter")]
  1394.     #[Route("/api/profiles/listing/city/{city}/list-pages/services", name: "api.profile_listing.list_pages.services", methods: "GET", format: "json")]
  1395.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1396.     #[OA\Tag(name: "ProfileListing")]
  1397.     #[OA\Response(
  1398.         response: 200,
  1399.         description: 'Листинг анкет для страницы списка услуг',
  1400.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1401.     )]
  1402.     public function intimServices(Request $request, City $city): Response
  1403.     {
  1404.         $isApiRequest = $this->isApiRequest($request);
  1405.         $servicesByGroup = $this->serviceRepository->allIndexedByGroup();
  1406.         $profilesOnListPages = null;
  1407.         $specs = null;
  1408.         if ($this->features->profiles_on_list_pages()) {
  1409.             $specs = $this->profileListSpecificationService->listPagesWithProvidedServices();
  1410.             $profilesOnListPages = $this->paginatedListing(
  1411.                 $city,
  1412.                 '/city/{city}/list-pages/services',
  1413.                 ['city' => $city->getId()],
  1414.                 $specs->spec(),
  1415.                 fallbackWithinCity: false
  1416.             );
  1417.         } elseif ($isApiRequest) {
  1418.             throw $this->createNotFoundException();
  1419.         }
  1420.         if ($isApiRequest) {
  1421.             return $this->jsonListingResponse($profilesOnListPages, $city, $specs);
  1422.         }
  1423.         return $this->render('ProfileList/intim_services.html.twig', [
  1424.             'city' => $city,
  1425.             'servicesByGroup' => $servicesByGroup,
  1426.             'profiles' => $profilesOnListPages,
  1427.             'profiles_on_list_pages' => $profilesOnListPages,
  1428.             'skipSetCurrentListingPage' => true,
  1429.         ]);
  1430.     }
  1431.     /**
  1432.      * @Feature("extra_category_outcall")
  1433.      */
  1434.     #[ParamConverter("city", converter: "city_converter")]
  1435.     #[Route("/api/profiles/listing/city/{city}/category/outcall", name: "api.profile_listing.category.outcall", methods: "GET", format: "json")]
  1436.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1437.     #[OA\Tag(name: "ProfileListing")]
  1438.     #[OA\Response(
  1439.         response: 200,
  1440.         description: '',
  1441.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1442.     )]
  1443.     public function listOutcall(Request $request, City $city): Response
  1444.     {
  1445.         $specs = $this->profileListSpecificationService->listByOutcall();
  1446.         $response = new Response();
  1447.         $result = $this->paginatedListing($city, '/city/{city}/category/outcall', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1448.         if ($this->isApiRequest($request)) {
  1449.             return $this->jsonListingResponse($result, $city, $specs);
  1450.         }
  1451.         return $this->render('ProfileList/list.html.twig', [
  1452.             'profiles' => $result,
  1453.             'source' => $this->source,
  1454.             'source_default' => 'outcall',
  1455.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1456.                 'city' => $city->getUriIdentity(),
  1457.                 'page' => $this->getCurrentPageNumber(),
  1458.             ]),
  1459.             'recommendationSpec' => $specs->recommendationSpec(),
  1460.         ], response: $response);
  1461.     }
  1462.     /**
  1463.      * @Feature("extra_category_dwarfs")
  1464.      */
  1465.     #[ParamConverter("city", converter: "city_converter")]
  1466.     #[Route("/api/profiles/listing/city/{city}/category/dwarfs", name: "api.profile_listing.category.dwarfs", methods: "GET", format: "json")]
  1467.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1468.     #[OA\Tag(name: "ProfileListing")]
  1469.     #[OA\Response(
  1470.         response: 200,
  1471.         description: '',
  1472.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1473.     )]
  1474.     public function listDwarfs(Request $request, City $city): Response
  1475.     {
  1476.         $specs = $this->profileListSpecificationService->listDwarfs();
  1477.         $response = new Response();
  1478.         $result = $this->paginatedListing($city, '/city/{city}/category/dwarfs', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1479.         if ($this->isApiRequest($request)) {
  1480.             return $this->jsonListingResponse($result, $city, $specs);
  1481.         }
  1482.         return $this->render('ProfileList/list.html.twig', [
  1483.             'profiles' => $result,
  1484.             'source' => $this->source,
  1485.             'source_default' => 'dwarfs',
  1486.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1487.                 'city' => $city->getUriIdentity(),
  1488.                 'page' => $this->getCurrentPageNumber(),
  1489.             ]),
  1490.             'recommendationSpec' => $specs->recommendationSpec(),
  1491.         ], response: $response);
  1492.     }
  1493.     #[ParamConverter("city", converter: "city_converter")]
  1494.     #[Route("/api/profiles/listing/city/{city}/with_selfie", name: "api.profile_listing.with_selfie", methods: "GET", format: "json")]
  1495.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1496.     #[OA\Tag(name: "ProfileListing")]
  1497.     #[OA\Response(
  1498.         response: 200,
  1499.         description: '',
  1500.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1501.     )]
  1502.     public function listWithSelfie(Request $request, City $city): Response
  1503.     {
  1504.         $specs = $this->profileListSpecificationService->listWithSelfie();
  1505.         $response = new Response();
  1506.         $result = $this->paginatedListing($city, '/city/{city}/with_selfie', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  1507.         if ($this->isApiRequest($request)) {
  1508.             return $this->jsonListingResponse($result, $city, $specs);
  1509.         }
  1510.         return $this->render('ProfileList/list.html.twig', [
  1511.             'profiles' => $result,
  1512.             'source' => $this->source,
  1513.             'source_default' => self::RESULT_SOURCE_WITH_SELFIE,
  1514.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1515.                 'city' => $city->getUriIdentity(),
  1516.                 'page' => $this->getCurrentPageNumber()
  1517.             ]),
  1518.             'recommendationSpec' => $specs->recommendationSpec(),
  1519.         ], response: $response);
  1520.     }
  1521.     /**
  1522.      * @Feature("extra_category_top_100")
  1523.      */
  1524.     #[ParamConverter("city", converter: "city_converter")]
  1525.     #[Route("/api/profiles/listing/city/{city}/category/top_100", name: "api.profile_listing.category.top_100", methods: "GET", format: "json")]
  1526.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1527.     #[OA\Tag(name: "ProfileListing")]
  1528.     #[OA\Response(
  1529.         response: 200,
  1530.         description: '',
  1531.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1532.     )]
  1533.     public function listTop100(Request $request, City $city): Response
  1534.     {
  1535.         $specs = $this->profileListSpecificationService->listApproved();
  1536.         $result = $this->top100ProfilesService->getSortedProfilesByVisits($city);
  1537.         if ($this->isApiRequest($request)) {
  1538.             return $this->jsonListingResponse($result, $city, $specs);
  1539.         }
  1540.         return $this->render('ProfileList/list.html.twig', [
  1541.             'profiles' => $result,
  1542.             'source' => self::RESULT_SOURCE_TOP_100,
  1543.             'source_default' => self::RESULT_SOURCE_TOP_100,
  1544.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1545.                 'city' => $city->getUriIdentity(),
  1546.                 'page' => $this->getCurrentPageNumber(),
  1547.             ]),
  1548.             'recommendationSpec' => $specs->recommendationSpec(),
  1549.         ]);
  1550.     }
  1551.     /**
  1552.      * @Feature("extra_category_eromassage")
  1553.      */
  1554.     #[ParamConverter("city", converter: "city_converter")]
  1555.     #[Entity("county", expr: "repository.ofUriIdentityWithinCity(county, city)")]
  1556.     #[Route("/api/profiles/listing/city/{city}/county/{county}/eromassage", name: "api.profile_listing.by_county_eromassage", methods: "GET", format: "json")]
  1557.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1558.     #[OA\Tag(name: "ProfileListing")]
  1559.     #[OA\Response(
  1560.         response: 200,
  1561.         description: '',
  1562.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1563.     )]
  1564.     public function listByCountyEromassage(Request $request, City $city, County $county): Response
  1565.     {
  1566.         if (!$city->hasCounty($county)) {
  1567.             throw $this->createNotFoundException();
  1568.         }
  1569.         $specs = $this->profileListSpecificationService->listByCountyEromassage($county);
  1570.         $response = new Response();
  1571.         $result = $this->paginatedListing(
  1572.             $city,
  1573.             '/city/{city}/county/{county}/eromassage',
  1574.             ['city' => $city->getId(), 'county' => $county->getId()],
  1575.             $specs->spec(),
  1576.             null,
  1577.             null,
  1578.             $response
  1579.         );
  1580.         if ($this->isApiRequest($request)) {
  1581.             return $this->jsonListingResponse($result, $city, $specs);
  1582.         }
  1583.         $request->attributes->set('profiles_count', $result->totalCount());
  1584.         return $this->render('ProfileList/list.html.twig', [
  1585.             'profiles' => $result,
  1586.             'source' => $this->source,
  1587.             'source_default' => self::RESULT_SOURCE_EROMASSAGE,
  1588.             'county' => $county,
  1589.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1590.                 'city' => $city->getUriIdentity(),
  1591.                 'county' => $county->getUriIdentity(),
  1592.                 'page' => $this->getCurrentPageNumber(),
  1593.             ]),
  1594.             'recommendationSpec' => $specs->recommendationSpec(),
  1595.         ], response: $response);
  1596.     }
  1597.     /**
  1598.      * @Feature("extra_category_eromassage")
  1599.      */
  1600.     #[ParamConverter("city", converter: "city_converter")]
  1601.     #[Entity("district", expr: "repository.ofUriIdentityWithinCity(district, city)")]
  1602.     #[Route("/api/profiles/listing/city/{city}/district/{district}/eromassage", name: "api.profile_listing.by_district_eromassage", methods: "GET", format: "json")]
  1603.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1604.     #[OA\Tag(name: "ProfileListing")]
  1605.     #[OA\Response(
  1606.         response: 200,
  1607.         description: '',
  1608.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1609.     )]
  1610.     public function listByDistrictEromassage(Request $request, City $city, District $district): Response
  1611.     {
  1612.         if (!$city->hasDistrict($district)) {
  1613.             throw $this->createNotFoundException();
  1614.         }
  1615.         $specs = $this->profileListSpecificationService->listByDistrictEromassage($district);
  1616.         $response = new Response();
  1617.         $result = $this->paginatedListing(
  1618.             $city,
  1619.             '/city/{city}/district/{district}/eromassage',
  1620.             ['city' => $city->getId(), 'district' => $district->getId()],
  1621.             $specs->spec(),
  1622.             null,
  1623.             null,
  1624.             $response
  1625.         );
  1626.         if ($this->isApiRequest($request)) {
  1627.             return $this->jsonListingResponse($result, $city, $specs);
  1628.         }
  1629.         $request->attributes->set('profiles_count', $result->totalCount());
  1630.         return $this->render('ProfileList/list.html.twig', [
  1631.             'profiles' => $result,
  1632.             'source' => $this->source,
  1633.             'source_default' => self::RESULT_SOURCE_EROMASSAGE,
  1634.             'district' => $district,
  1635.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1636.                 'city' => $city->getUriIdentity(),
  1637.                 'district' => $district->getUriIdentity(),
  1638.                 'page' => $this->getCurrentPageNumber(),
  1639.             ]),
  1640.             'recommendationSpec' => $specs->recommendationSpec(),
  1641.         ], response: $response);
  1642.     }
  1643.     /**
  1644.      * @Feature("extra_category_eromassage")
  1645.      */
  1646.     #[ParamConverter("city", converter: "city_converter")]
  1647.     #[Entity("station", expr: "repository.ofUriIdentityWithinCity(station, city)")]
  1648.     #[Route("/api/profiles/listing/city/{city}/station/{station}/eromassage", name: "api.profile_listing.by_station_eromassage", methods: "GET", format: "json")]
  1649.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1650.     #[OA\Tag(name: "ProfileListing")]
  1651.     #[OA\Response(
  1652.         response: 200,
  1653.         description: '',
  1654.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1655.     )]
  1656.     public function listByStationEromassage(Request $request, City $city, Station $station): Response
  1657.     {
  1658.         if (!$city->hasStation($station)) {
  1659.             throw $this->createNotFoundException();
  1660.         }
  1661.         $specs = $this->profileListSpecificationService->listByStationEromassage($station);
  1662.         $response = new Response();
  1663.         $result = $this->paginatedListing(
  1664.             $city,
  1665.             '/city/{city}/station/{station}/eromassage',
  1666.             ['city' => $city->getId(), 'station' => $station->getId()],
  1667.             $specs->spec(),
  1668.             null,
  1669.             null,
  1670.             $response
  1671.         );
  1672.         if ($this->isApiRequest($request)) {
  1673.             return $this->jsonListingResponse($result, $city, $specs);
  1674.         }
  1675.         $request->attributes->set('profiles_count', $result->totalCount());
  1676.         return $this->render('ProfileList/list.html.twig', [
  1677.             'profiles' => $result,
  1678.             'source' => $this->source,
  1679.             'source_default' => self::RESULT_SOURCE_EROMASSAGE,
  1680.             'station' => $station,
  1681.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1682.                 'city' => $city->getUriIdentity(),
  1683.                 'station' => $station->getUriIdentity(),
  1684.                 'page' => $this->getCurrentPageNumber(),
  1685.             ]),
  1686.             'recommendationSpec' => $specs->recommendationSpec(),
  1687.         ], response: $response);
  1688.     }
  1689.     /**
  1690.      * @Feature("extra_category_verified")
  1691.      */
  1692.     #[ParamConverter("city", converter: "city_converter")]
  1693.     #[Entity("county", expr: "repository.ofUriIdentityWithinCity(county, city)")]
  1694.     #[Route("/api/profiles/listing/city/{city}/county/{county}/proverennye", name: "api.profile_listing.by_county_verified", methods: "GET", format: "json")]
  1695.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1696.     #[OA\Tag(name: "ProfileListing")]
  1697.     #[OA\Response(
  1698.         response: 200,
  1699.         description: '',
  1700.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1701.     )]
  1702.     public function listByCountyVerified(Request $request, City $city, County $county): Response
  1703.     {
  1704.         if (!$city->hasCounty($county)) {
  1705.             throw $this->createNotFoundException();
  1706.         }
  1707.         $specs = $this->profileListSpecificationService->listByCountyVerified($county);
  1708.         $response = new Response();
  1709.         $result = $this->paginatedListing(
  1710.             $city,
  1711.             '/city/{city}/county/{county}/proverennye',
  1712.             ['city' => $city->getId(), 'county' => $county->getId()],
  1713.             $specs->spec(),
  1714.             null,
  1715.             null,
  1716.             $response
  1717.         );
  1718.         if ($this->isApiRequest($request)) {
  1719.             return $this->jsonListingResponse($result, $city, $specs);
  1720.         }
  1721.         $request->attributes->set('profiles_count', $result->totalCount());
  1722.         return $this->render('ProfileList/list.html.twig', [
  1723.             'profiles' => $result,
  1724.             'source' => $this->source,
  1725.             'source_default' => self::RESULT_SOURCE_VERIFIED,
  1726.             'county' => $county,
  1727.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1728.                 'city' => $city->getUriIdentity(),
  1729.                 'county' => $county->getUriIdentity(),
  1730.                 'page' => $this->getCurrentPageNumber(),
  1731.             ]),
  1732.             'recommendationSpec' => $specs->recommendationSpec(),
  1733.         ], response: $response);
  1734.     }
  1735.     /**
  1736.      * @Feature("extra_category_verified")
  1737.      */
  1738.     #[ParamConverter("city", converter: "city_converter")]
  1739.     #[Entity("district", expr: "repository.ofUriIdentityWithinCity(district, city)")]
  1740.     #[Route("/api/profiles/listing/city/{city}/district/{district}/proverennye", name: "api.profile_listing.by_district_verified", methods: "GET", format: "json")]
  1741.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1742.     #[OA\Tag(name: "ProfileListing")]
  1743.     #[OA\Response(
  1744.         response: 200,
  1745.         description: '',
  1746.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1747.     )]
  1748.     public function listByDistrictVerified(Request $request, City $city, District $district): Response
  1749.     {
  1750.         if (!$city->hasDistrict($district)) {
  1751.             throw $this->createNotFoundException();
  1752.         }
  1753.         $specs = $this->profileListSpecificationService->listByDistrictVerified($district);
  1754.         $response = new Response();
  1755.         $result = $this->paginatedListing(
  1756.             $city,
  1757.             '/city/{city}/district/{district}/proverennye',
  1758.             ['city' => $city->getId(), 'district' => $district->getId()],
  1759.             $specs->spec(),
  1760.             null,
  1761.             null,
  1762.             $response
  1763.         );
  1764.         if ($this->isApiRequest($request)) {
  1765.             return $this->jsonListingResponse($result, $city, $specs);
  1766.         }
  1767.         $request->attributes->set('profiles_count', $result->totalCount());
  1768.         return $this->render('ProfileList/list.html.twig', [
  1769.             'profiles' => $result,
  1770.             'source' => $this->source,
  1771.             'source_default' => self::RESULT_SOURCE_VERIFIED,
  1772.             'district' => $district,
  1773.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1774.                 'city' => $city->getUriIdentity(),
  1775.                 'district' => $district->getUriIdentity(),
  1776.                 'page' => $this->getCurrentPageNumber(),
  1777.             ]),
  1778.             'recommendationSpec' => $specs->recommendationSpec(),
  1779.         ], response: $response);
  1780.     }
  1781.     /**
  1782.      * @Feature("extra_category_verified")
  1783.      */
  1784.     #[ParamConverter("city", converter: "city_converter")]
  1785.     #[Entity("station", expr: "repository.ofUriIdentityWithinCity(station, city)")]
  1786.     #[Route("/api/profiles/listing/city/{city}/station/{station}/proverennye", name: "api.profile_listing.by_station_verified", methods: "GET", format: "json")]
  1787.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1788.     #[OA\Tag(name: "ProfileListing")]
  1789.     #[OA\Response(
  1790.         response: 200,
  1791.         description: '',
  1792.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1793.     )]
  1794.     public function listByStationVerified(Request $request, City $city, Station $station): Response
  1795.     {
  1796.         if (!$city->hasStation($station)) {
  1797.             throw $this->createNotFoundException();
  1798.         }
  1799.         $specs = $this->profileListSpecificationService->listByStationVerified($station);
  1800.         $response = new Response();
  1801.         $result = $this->paginatedListing(
  1802.             $city,
  1803.             '/city/{city}/station/{station}/proverennye',
  1804.             ['city' => $city->getId(), 'station' => $station->getId()],
  1805.             $specs->spec(),
  1806.             null,
  1807.             null,
  1808.             $response
  1809.         );
  1810.         if ($this->isApiRequest($request)) {
  1811.             return $this->jsonListingResponse($result, $city, $specs);
  1812.         }
  1813.         $request->attributes->set('profiles_count', $result->totalCount());
  1814.         return $this->render('ProfileList/list.html.twig', [
  1815.             'profiles' => $result,
  1816.             'source' => $this->source,
  1817.             'source_default' => self::RESULT_SOURCE_VERIFIED,
  1818.             'station' => $station,
  1819.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1820.                 'city' => $city->getUriIdentity(),
  1821.                 'station' => $station->getUriIdentity(),
  1822.                 'page' => $this->getCurrentPageNumber(),
  1823.             ]),
  1824.             'recommendationSpec' => $specs->recommendationSpec(),
  1825.         ], response: $response);
  1826.     }
  1827.     /**
  1828.      * @Feature("extra_category_cheap")
  1829.      */
  1830.     #[ParamConverter("city", converter: "city_converter")]
  1831.     #[Entity("county", expr: "repository.ofUriIdentityWithinCity(county, city)")]
  1832.     #[Route("/api/profiles/listing/city/{city}/county/{county}/deshevye", name: "api.profile_listing.by_county_cheap", methods: "GET", format: "json")]
  1833.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1834.     #[OA\Tag(name: "ProfileListing")]
  1835.     #[OA\Response(
  1836.         response: 200,
  1837.         description: '',
  1838.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1839.     )]
  1840.     public function listByCountyCheap(Request $request, City $city, County $county): Response
  1841.     {
  1842.         if (!$city->hasCounty($county)) {
  1843.             throw $this->createNotFoundException();
  1844.         }
  1845.         $specs = $this->profileListSpecificationService->listByCountyCheap($county);
  1846.         $response = new Response();
  1847.         $result = $this->paginatedListing(
  1848.             $city,
  1849.             null,
  1850.             [],
  1851.             $specs->spec(),
  1852.             null,
  1853.             null,
  1854.             $response
  1855.         );
  1856.         if ($this->isApiRequest($request)) {
  1857.             return $this->jsonListingResponse($result, $city, $specs);
  1858.         }
  1859.         $request->attributes->set('profiles_count', $result->totalCount());
  1860.         return $this->render('ProfileList/list.html.twig', [
  1861.             'profiles' => $result,
  1862.             'source' => $this->source,
  1863.             'source_default' => self::RESULT_SOURCE_CHEAP,
  1864.             'county' => $county,
  1865.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1866.                 'city' => $city->getUriIdentity(),
  1867.                 'county' => $county->getUriIdentity(),
  1868.                 'page' => $this->getCurrentPageNumber(),
  1869.             ]),
  1870.             'recommendationSpec' => $specs->recommendationSpec(),
  1871.         ], response: $response);
  1872.     }
  1873.     /**
  1874.      * @Feature("extra_category_cheap")
  1875.      */
  1876.     #[ParamConverter("city", converter: "city_converter")]
  1877.     #[Entity("district", expr: "repository.ofUriIdentityWithinCity(district, city)")]
  1878.     #[Route("/api/profiles/listing/city/{city}/district/{district}/deshevye", name: "api.profile_listing.by_district_cheap", methods: "GET", format: "json")]
  1879.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1880.     #[OA\Tag(name: "ProfileListing")]
  1881.     #[OA\Response(
  1882.         response: 200,
  1883.         description: '',
  1884.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1885.     )]
  1886.     public function listByDistrictCheap(Request $request, City $city, District $district): Response
  1887.     {
  1888.         if (!$city->hasDistrict($district)) {
  1889.             throw $this->createNotFoundException();
  1890.         }
  1891.         $specs = $this->profileListSpecificationService->listByDistrictCheap($district);
  1892.         $response = new Response();
  1893.         $result = $this->paginatedListing(
  1894.             $city,
  1895.             null,
  1896.             [],
  1897.             $specs->spec(),
  1898.             null,
  1899.             null,
  1900.             $response
  1901.         );
  1902.         if ($this->isApiRequest($request)) {
  1903.             return $this->jsonListingResponse($result, $city, $specs);
  1904.         }
  1905.         $request->attributes->set('profiles_count', $result->totalCount());
  1906.         return $this->render('ProfileList/list.html.twig', [
  1907.             'profiles' => $result,
  1908.             'source' => $this->source,
  1909.             'source_default' => self::RESULT_SOURCE_CHEAP,
  1910.             'district' => $district,
  1911.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1912.                 'city' => $city->getUriIdentity(),
  1913.                 'district' => $district->getUriIdentity(),
  1914.                 'page' => $this->getCurrentPageNumber(),
  1915.             ]),
  1916.             'recommendationSpec' => $specs->recommendationSpec(),
  1917.         ], response: $response);
  1918.     }
  1919.     /**
  1920.      * @Feature("extra_category_cheap")
  1921.      */
  1922.     #[ParamConverter("city", converter: "city_converter")]
  1923.     #[Entity("station", expr: "repository.ofUriIdentityWithinCity(station, city)")]
  1924.     #[Route("/api/profiles/listing/city/{city}/station/{station}/deshevye", name: "api.profile_listing.by_station_cheap", methods: "GET", format: "json")]
  1925.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1926.     #[OA\Tag(name: "ProfileListing")]
  1927.     #[OA\Response(
  1928.         response: 200,
  1929.         description: '',
  1930.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1931.     )]
  1932.     public function listByStationCheap(Request $request, City $city, Station $station): Response
  1933.     {
  1934.         if (!$city->hasStation($station)) {
  1935.             throw $this->createNotFoundException();
  1936.         }
  1937.         $specs = $this->profileListSpecificationService->listByStationCheap($station);
  1938.         $response = new Response();
  1939.         $result = $this->paginatedListing(
  1940.             $city,
  1941.             null,
  1942.             [],
  1943.             $specs->spec(),
  1944.             null,
  1945.             null,
  1946.             $response
  1947.         );
  1948.         if ($this->isApiRequest($request)) {
  1949.             return $this->jsonListingResponse($result, $city, $specs);
  1950.         }
  1951.         $request->attributes->set('profiles_count', $result->totalCount());
  1952.         return $this->render('ProfileList/list.html.twig', [
  1953.             'profiles' => $result,
  1954.             'source' => $this->source,
  1955.             'source_default' => self::RESULT_SOURCE_CHEAP,
  1956.             'station' => $station,
  1957.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1958.                 'city' => $city->getUriIdentity(),
  1959.                 'station' => $station->getUriIdentity(),
  1960.                 'page' => $this->getCurrentPageNumber(),
  1961.             ]),
  1962.             'recommendationSpec' => $specs->recommendationSpec(),
  1963.         ], response: $response);
  1964.     }
  1965.     /**
  1966.      * @Feature("extra_category_mature")
  1967.      */
  1968.     #[ParamConverter("city", converter: "city_converter")]
  1969.     #[Entity("county", expr: "repository.ofUriIdentityWithinCity(county, city)")]
  1970.     #[Route("/api/profiles/listing/city/{city}/county/{county}/zrelye", name: "api.profile_listing.by_county_mature", methods: "GET", format: "json")]
  1971.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  1972.     #[OA\Tag(name: "ProfileListing")]
  1973.     #[OA\Response(
  1974.         response: 200,
  1975.         description: '',
  1976.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  1977.     )]
  1978.     public function listByCountyMature(Request $request, City $city, County $county): Response
  1979.     {
  1980.         if (!$city->hasCounty($county)) {
  1981.             throw $this->createNotFoundException();
  1982.         }
  1983.         $specs = $this->profileListSpecificationService->listByCountyMature($county);
  1984.         $response = new Response();
  1985.         $result = $this->paginatedListing(
  1986.             $city,
  1987.             null,
  1988.             [],
  1989.             $specs->spec(),
  1990.             null,
  1991.             null,
  1992.             $response
  1993.         );
  1994.         if ($this->isApiRequest($request)) {
  1995.             return $this->jsonListingResponse($result, $city, $specs);
  1996.         }
  1997.         $request->attributes->set('profiles_count', $result->totalCount());
  1998.         return $this->render('ProfileList/list.html.twig', [
  1999.             'profiles' => $result,
  2000.             'source' => $this->source,
  2001.             'source_default' => self::RESULT_SOURCE_MATURE,
  2002.             'county' => $county,
  2003.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2004.                 'city' => $city->getUriIdentity(),
  2005.                 'county' => $county->getUriIdentity(),
  2006.                 'page' => $this->getCurrentPageNumber(),
  2007.             ]),
  2008.             'recommendationSpec' => $specs->recommendationSpec(),
  2009.         ], response: $response);
  2010.     }
  2011.     /**
  2012.      * @Feature("extra_category_mature")
  2013.      */
  2014.     #[ParamConverter("city", converter: "city_converter")]
  2015.     #[Entity("district", expr: "repository.ofUriIdentityWithinCity(district, city)")]
  2016.     #[Route("/api/profiles/listing/city/{city}/district/{district}/zrelye", name: "api.profile_listing.by_district_mature", methods: "GET", format: "json")]
  2017.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2018.     #[OA\Tag(name: "ProfileListing")]
  2019.     #[OA\Response(
  2020.         response: 200,
  2021.         description: '',
  2022.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2023.     )]
  2024.     public function listByDistrictMature(Request $request, City $city, District $district): Response
  2025.     {
  2026.         if (!$city->hasDistrict($district)) {
  2027.             throw $this->createNotFoundException();
  2028.         }
  2029.         $specs = $this->profileListSpecificationService->listByDistrictMature($district);
  2030.         $response = new Response();
  2031.         $result = $this->paginatedListing(
  2032.             $city,
  2033.             null,
  2034.             [],
  2035.             $specs->spec(),
  2036.             null,
  2037.             null,
  2038.             $response
  2039.         );
  2040.         if ($this->isApiRequest($request)) {
  2041.             return $this->jsonListingResponse($result, $city, $specs);
  2042.         }
  2043.         $request->attributes->set('profiles_count', $result->totalCount());
  2044.         return $this->render('ProfileList/list.html.twig', [
  2045.             'profiles' => $result,
  2046.             'source' => $this->source,
  2047.             'source_default' => self::RESULT_SOURCE_MATURE,
  2048.             'district' => $district,
  2049.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2050.                 'city' => $city->getUriIdentity(),
  2051.                 'district' => $district->getUriIdentity(),
  2052.                 'page' => $this->getCurrentPageNumber(),
  2053.             ]),
  2054.             'recommendationSpec' => $specs->recommendationSpec(),
  2055.         ], response: $response);
  2056.     }
  2057.     /**
  2058.      * @Feature("extra_category_mature")
  2059.      */
  2060.     #[ParamConverter("city", converter: "city_converter")]
  2061.     #[Entity("station", expr: "repository.ofUriIdentityWithinCity(station, city)")]
  2062.     #[Route("/api/profiles/listing/city/{city}/station/{station}/zrelye", name: "api.profile_listing.by_station_mature", methods: "GET", format: "json")]
  2063.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2064.     #[OA\Tag(name: "ProfileListing")]
  2065.     #[OA\Response(
  2066.         response: 200,
  2067.         description: '',
  2068.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2069.     )]
  2070.     public function listByStationMature(Request $request, City $city, Station $station): Response
  2071.     {
  2072.         if (!$city->hasStation($station)) {
  2073.             throw $this->createNotFoundException();
  2074.         }
  2075.         $specs = $this->profileListSpecificationService->listByStationMature($station);
  2076.         $response = new Response();
  2077.         $result = $this->paginatedListing(
  2078.             $city,
  2079.             null,
  2080.             [],
  2081.             $specs->spec(),
  2082.             null,
  2083.             null,
  2084.             $response
  2085.         );
  2086.         if ($this->isApiRequest($request)) {
  2087.             return $this->jsonListingResponse($result, $city, $specs);
  2088.         }
  2089.         $request->attributes->set('profiles_count', $result->totalCount());
  2090.         return $this->render('ProfileList/list.html.twig', [
  2091.             'profiles' => $result,
  2092.             'source' => $this->source,
  2093.             'source_default' => self::RESULT_SOURCE_MATURE,
  2094.             'station' => $station,
  2095.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2096.                 'city' => $city->getUriIdentity(),
  2097.                 'station' => $station->getUriIdentity(),
  2098.                 'page' => $this->getCurrentPageNumber(),
  2099.             ]),
  2100.             'recommendationSpec' => $specs->recommendationSpec(),
  2101.         ], response: $response);
  2102.     }
  2103.     /**
  2104.      * @Feature("extra_category_uzbek")
  2105.      */
  2106.     #[ParamConverter("city", converter: "city_converter")]
  2107.     #[Entity("county", expr: "repository.ofUriIdentityWithinCity(county, city)")]
  2108.     #[Route("/api/profiles/listing/city/{city}/county/{county}/uzbechki", name: "api.profile_listing.by_county_uzbek", methods: "GET", format: "json")]
  2109.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2110.     #[OA\Tag(name: "ProfileListing")]
  2111.     #[OA\Response(
  2112.         response: 200,
  2113.         description: '',
  2114.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2115.     )]
  2116.     public function listByCountyUzbek(Request $request, City $city, County $county): Response
  2117.     {
  2118.         if (!$city->hasCounty($county)) {
  2119.             throw $this->createNotFoundException();
  2120.         }
  2121.         $specs = $this->profileListSpecificationService->listByCountyUzbek($county);
  2122.         $response = new Response();
  2123.         $result = $this->paginatedListing(
  2124.             $city,
  2125.             '/city/{city}/county/{county}/uzbechki',
  2126.             ['city' => $city->getId(), 'county' => $county->getId()],
  2127.             $specs->spec(),
  2128.             null,
  2129.             null,
  2130.             $response
  2131.         );
  2132.         if ($this->isApiRequest($request)) {
  2133.             return $this->jsonListingResponse($result, $city, $specs);
  2134.         }
  2135.         $request->attributes->set('profiles_count', $result->totalCount());
  2136.         return $this->render('ProfileList/list.html.twig', [
  2137.             'profiles' => $result,
  2138.             'source' => $this->source,
  2139.             'source_default' => self::RESULT_SOURCE_UZBEK,
  2140.             'county' => $county,
  2141.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2142.                 'city' => $city->getUriIdentity(),
  2143.                 'county' => $county->getUriIdentity(),
  2144.                 'page' => $this->getCurrentPageNumber(),
  2145.             ]),
  2146.             'recommendationSpec' => $specs->recommendationSpec(),
  2147.         ], response: $response);
  2148.     }
  2149.     /**
  2150.      * @Feature("extra_category_uzbek")
  2151.      */
  2152.     #[ParamConverter("city", converter: "city_converter")]
  2153.     #[Entity("district", expr: "repository.ofUriIdentityWithinCity(district, city)")]
  2154.     #[Route("/api/profiles/listing/city/{city}/district/{district}/uzbechki", name: "api.profile_listing.by_district_uzbek", methods: "GET", format: "json")]
  2155.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2156.     #[OA\Tag(name: "ProfileListing")]
  2157.     #[OA\Response(
  2158.         response: 200,
  2159.         description: '',
  2160.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2161.     )]
  2162.     public function listByDistrictUzbek(Request $request, City $city, District $district): Response
  2163.     {
  2164.         if (!$city->hasDistrict($district)) {
  2165.             throw $this->createNotFoundException();
  2166.         }
  2167.         $specs = $this->profileListSpecificationService->listByDistrictUzbek($district);
  2168.         $response = new Response();
  2169.         $result = $this->paginatedListing(
  2170.             $city,
  2171.             '/city/{city}/district/{district}/uzbechki',
  2172.             ['city' => $city->getId(), 'district' => $district->getId()],
  2173.             $specs->spec(),
  2174.             null,
  2175.             null,
  2176.             $response
  2177.         );
  2178.         if ($this->isApiRequest($request)) {
  2179.             return $this->jsonListingResponse($result, $city, $specs);
  2180.         }
  2181.         $request->attributes->set('profiles_count', $result->totalCount());
  2182.         return $this->render('ProfileList/list.html.twig', [
  2183.             'profiles' => $result,
  2184.             'source' => $this->source,
  2185.             'source_default' => self::RESULT_SOURCE_UZBEK,
  2186.             'district' => $district,
  2187.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2188.                 'city' => $city->getUriIdentity(),
  2189.                 'district' => $district->getUriIdentity(),
  2190.                 'page' => $this->getCurrentPageNumber(),
  2191.             ]),
  2192.             'recommendationSpec' => $specs->recommendationSpec(),
  2193.         ], response: $response);
  2194.     }
  2195.     /**
  2196.      * @Feature("extra_category_uzbek")
  2197.      */
  2198.     #[ParamConverter("city", converter: "city_converter")]
  2199.     #[Entity("station", expr: "repository.ofUriIdentityWithinCity(station, city)")]
  2200.     #[Route("/api/profiles/listing/city/{city}/station/{station}/uzbechki", name: "api.profile_listing.by_station_uzbek", methods: "GET", format: "json")]
  2201.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2202.     #[OA\Tag(name: "ProfileListing")]
  2203.     #[OA\Response(
  2204.         response: 200,
  2205.         description: '',
  2206.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2207.     )]
  2208.     public function listByStationUzbek(Request $request, City $city, Station $station): Response
  2209.     {
  2210.         if (!$city->hasStation($station)) {
  2211.             throw $this->createNotFoundException();
  2212.         }
  2213.         $specs = $this->profileListSpecificationService->listByStationUzbek($station);
  2214.         $response = new Response();
  2215.         $result = $this->paginatedListing(
  2216.             $city,
  2217.             '/city/{city}/station/{station}/uzbechki',
  2218.             ['city' => $city->getId(), 'station' => $station->getId()],
  2219.             $specs->spec(),
  2220.             null,
  2221.             null,
  2222.             $response
  2223.         );
  2224.         if ($this->isApiRequest($request)) {
  2225.             return $this->jsonListingResponse($result, $city, $specs);
  2226.         }
  2227.         $request->attributes->set('profiles_count', $result->totalCount());
  2228.         return $this->render('ProfileList/list.html.twig', [
  2229.             'profiles' => $result,
  2230.             'source' => $this->source,
  2231.             'source_default' => self::RESULT_SOURCE_UZBEK,
  2232.             'station' => $station,
  2233.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2234.                 'city' => $city->getUriIdentity(),
  2235.                 'station' => $station->getUriIdentity(),
  2236.                 'page' => $this->getCurrentPageNumber(),
  2237.             ]),
  2238.             'recommendationSpec' => $specs->recommendationSpec(),
  2239.         ], response: $response);
  2240.     }
  2241.     #[ParamConverter("city", converter: "city_converter")]
  2242.     #[Route("/api/profiles/listing/city/{city}/price/{priceType}", name: "api.profile_listing.by_price", methods: "GET", format: "json")]
  2243.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2244.     #[OA\Parameter(name: "minPrice", description: "Min price for price type 'range'. 0 to omit.", in: "query", schema: new OA\Schema(type: "integer", default: 0, minimum: 0))]
  2245.     #[OA\Parameter(name: "maxPrice", description: "Max price for price types 'range' and 'less_than'. 0 to omit.", in: "query", schema: new OA\Schema(type: "integer", default: 0, minimum: 0))]
  2246.     #[OA\Tag(name: "ProfileListing")]
  2247.     #[OA\Response(
  2248.         response: 200,
  2249.         description: '',
  2250.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2251.     )]
  2252.     public function listByPrice(Request $request, CountryCurrencyResolver $countryCurrencyResolver, City $city, string $priceType, int $minPrice = null, int $maxPrice = null): Response
  2253.     {
  2254.         if ($this->isApiRequest($request) && in_array($priceType, ['range', 'less_than'], true)) {
  2255.             $minPrice = $request->query->getInt('minPrice');
  2256.             $maxPrice = $request->query->getInt('maxPrice');
  2257.             if ('range' === $priceType && 0 === $minPrice && 0 === $maxPrice) {
  2258.                 throw new \InvalidArgumentException('Either minPrice or maxPrice is required for price type "range".');
  2259.             }
  2260.             if ('less_than' === $priceType && 0 === $maxPrice) {
  2261.                 throw new \InvalidArgumentException('MaxPrice is required for price type "less_than".');
  2262.             }
  2263.         }
  2264.         $specs = $this->profileListSpecificationService->listByPrice($city, $priceType, $minPrice, $maxPrice);
  2265.         $response = new Response();
  2266.         $apiEndpoint = match ($priceType) {
  2267.             'low', 'high', 'elite' => '/city/{city}/price/'.$priceType,
  2268.             'less_than' => '/city/{city}/price/less_than/{maxPrice}',
  2269.             default => null,
  2270.         };
  2271.         $result = $this->paginatedListing($city, $apiEndpoint, [
  2272.             'city' => $city->getId(),
  2273.             'maxPrice' => $maxPrice,
  2274.         ], $specs->spec(), null, null, $response);
  2275.         if ($this->isApiRequest($request)) {
  2276.             return $this->jsonListingResponse($result, $city, $specs);
  2277.         }
  2278.         $request->attributes->set('profiles_count', $result->totalCount());
  2279.         return $this->render('ProfileList/list.html.twig', [
  2280.             'profiles' => $result,
  2281.             'source' => $this->source,
  2282.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2283.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2284.                 'city' => $city->getUriIdentity(),
  2285.                 'priceType' => $priceType,
  2286.                 'minPrice' => $minPrice,
  2287.                 'maxPrice' => $maxPrice,
  2288.                 'page' => $this->getCurrentPageNumber()
  2289.             ]),
  2290.             'recommendationSpec' => 'less_than' === $priceType ? null : $specs->recommendationSpec(),
  2291.             'skip_listing_recommendations' => 'less_than' === $priceType,
  2292.         ], response: $response);
  2293.     }
  2294.     #[ParamConverter("city", converter: "city_converter")]
  2295.     #[Route("/api/profiles/listing/city/{city}/age/{ageType}", name: "api.profile_listing.by_age", methods: "GET", format: "json")]
  2296.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2297.     #[OA\Tag(name: "ProfileListing")]
  2298.     #[OA\Response(
  2299.         response: 200,
  2300.         description: '',
  2301.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2302.     )]
  2303.     public function listByAge(Request $request, City $city, string $ageType, int $minAge = null, int $maxAge = null): Response
  2304.     {
  2305.         $specs = $this->profileListSpecificationService->listByAge($ageType, $minAge, $maxAge);
  2306.         $response = new Response();
  2307.         $apiEndpoint = in_array($ageType, ['young', 'old']) ? '/city/{city}/age/'.$ageType : null;
  2308.         $result = $this->paginatedListing($city, $apiEndpoint, ['city' => $city->getId()], $specs->spec(), null, null, $response);
  2309.         if ($this->isApiRequest($request)) {
  2310.             return $this->jsonListingResponse($result, $city, $specs);
  2311.         }
  2312.         return $this->render('ProfileList/list.html.twig', [
  2313.             'profiles' => $result,
  2314.             'source' => $this->source,
  2315.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2316.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2317.                 'city' => $city->getUriIdentity(),
  2318.                 'ageType' => $ageType,
  2319.                 'minAge' => $minAge,
  2320.                 'maxAge' => $maxAge,
  2321.                 'page' => $this->getCurrentPageNumber()
  2322.             ]),
  2323.             'recommendationSpec' => $specs->recommendationSpec(),
  2324.         ], response: $response);
  2325.     }
  2326.     #[ParamConverter("city", converter: "city_converter")]
  2327.     #[Route("/api/profiles/listing/city/{city}/height/{heightType}", name: "api.profile_listing.by_height", methods: "GET", format: "json")]
  2328.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2329.     #[OA\Tag(name: "ProfileListing")]
  2330.     #[OA\Response(
  2331.         response: 200,
  2332.         description: '',
  2333.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2334.     )]
  2335.     public function listByHeight(Request $request, City $city, string $heightType): Response
  2336.     {
  2337.         $specs = $this->profileListSpecificationService->listByHeight($heightType);
  2338.         $response = new Response();
  2339.         $result = $this->paginatedListing($city, '/city/{city}/height/'.$heightType, ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  2340.         if ($this->isApiRequest($request)) {
  2341.             return $this->jsonListingResponse($result, $city, $specs);
  2342.         }
  2343.         return $this->render('ProfileList/list.html.twig', [
  2344.             'profiles' => $result,
  2345.             'source' => $this->source,
  2346.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2347.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2348.                 'city' => $city->getUriIdentity(),
  2349.                 'heightType' => $heightType,
  2350.                 'page' => $this->getCurrentPageNumber()
  2351.             ]),
  2352.             'recommendationSpec' => $specs->recommendationSpec(),
  2353.         ], response: $response);
  2354.     }
  2355.     #[ParamConverter("city", converter: "city_converter")]
  2356.     #[Route("/api/profiles/listing/city/{city}/breasttype/{breastType}", name: "api.profile_listing.by_breast_type", methods: "GET", format: "json")]
  2357.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2358.     #[OA\Tag(name: "ProfileListing")]
  2359.     #[OA\Response(
  2360.         response: 200,
  2361.         description: '',
  2362.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2363.     )]
  2364.     public function listByBreastType(Request $request, City $city, string $breastType): Response
  2365.     {
  2366.         if (null === $type = BreastTypes::getValueByUriIdentity($breastType)) {
  2367.             throw $this->createNotFoundException();
  2368.         }
  2369.         $specs = $this->profileListSpecificationService->listByBreastType($breastType);
  2370.         $response = new Response();
  2371.         $alternativeSpec = $this->getORSpecForItemsArray(BreastTypes::getList(), function($item): ProfileWithBreastType {
  2372.             return new ProfileWithBreastType($item);
  2373.         });
  2374.         $result = $this->paginatedListing($city, '/city/{city}/breasttype/'.$type, ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_BY_PARAMS, $response);
  2375.         if ($this->isApiRequest($request)) {
  2376.             return $this->jsonListingResponse($result, $city, $specs);
  2377.         }
  2378.         return $this->render('ProfileList/list.html.twig', [
  2379.             'profiles' => $result,
  2380.             'source' => $this->source,
  2381.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2382.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2383.                 'city' => $city->getUriIdentity(),
  2384.                 'breastType' => $breastType,
  2385.                 'page' => $this->getCurrentPageNumber()
  2386.             ]),
  2387.             'recommendationSpec' => $specs->recommendationSpec(),
  2388.         ], response: $response);
  2389.     }
  2390.     #[ParamConverter("city", converter: "city_converter")]
  2391.     #[Route("/api/profiles/listing/city/{city}/haircolor/{hairColor}", name: "api.profile_listing.by_haircolor", methods: "GET", format: "json")]
  2392.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2393.     #[OA\Tag(name: "ProfileListing")]
  2394.     #[OA\Response(
  2395.         response: 200,
  2396.         description: '',
  2397.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2398.     )]
  2399.     public function listByHairColor(Request $request, City $city, string $hairColor): Response
  2400.     {
  2401.         if (null === $color = HairColors::getValueByUriIdentity($hairColor)) {
  2402.             throw $this->createNotFoundException();
  2403.         }
  2404.         $specs = $this->profileListSpecificationService->listByHairColor($hairColor);
  2405.         $response = new Response();
  2406.         $alternativeSpec = $this->getORSpecForItemsArray(HairColors::getList(), function($item): ProfileWithHairColor {
  2407.             return new ProfileWithHairColor($item);
  2408.         });
  2409.         $result = $this->paginatedListing($city, '/city/{city}/haircolor/'.$color, ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_BY_PARAMS, $response);
  2410.         if ($this->isApiRequest($request)) {
  2411.             return $this->jsonListingResponse($result, $city, $specs);
  2412.         }
  2413.         return $this->render('ProfileList/list.html.twig', [
  2414.             'profiles' => $result,
  2415.             'source' => $this->source,
  2416.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2417.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2418.                 'city' => $city->getUriIdentity(),
  2419.                 'hairColor' => $hairColor,
  2420.                 'page' => $this->getCurrentPageNumber()
  2421.             ]),
  2422.             'recommendationSpec' => $specs->recommendationSpec(),
  2423.         ], response: $response);
  2424.     }
  2425.     #[ParamConverter("city", converter: "city_converter")]
  2426.     #[Route("/api/profiles/listing/city/{city}/bodytype/{bodyType}", name: "api.profile_listing.by_bodytype", methods: "GET", format: "json")]
  2427.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2428.     #[OA\Tag(name: "ProfileListing")]
  2429.     #[OA\Response(
  2430.         response: 200,
  2431.         description: '',
  2432.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2433.     )]
  2434.     public function listByBodyType(Request $request, City $city, string $bodyType): Response
  2435.     {
  2436.         if (null === $type = BodyTypes::getValueByUriIdentity($bodyType)) {
  2437.             throw $this->createNotFoundException();
  2438.         }
  2439.         $specs = $this->profileListSpecificationService->listByBodyType($bodyType);
  2440.         $response = new Response();
  2441.         $alternativeSpec = $this->getORSpecForItemsArray(BodyTypes::getList(), function($item): ProfileWithBodyType {
  2442.             return new ProfileWithBodyType($item);
  2443.         });
  2444.         $result = $this->paginatedListing($city, '/city/{city}/bodytype/'.$type, ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_BY_PARAMS, $response);
  2445.         if ($this->isApiRequest($request)) {
  2446.             return $this->jsonListingResponse($result, $city, $specs);
  2447.         }
  2448.         return $this->render('ProfileList/list.html.twig', [
  2449.             'profiles' => $result,
  2450.             'source' => $this->source,
  2451.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2452.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2453.                 'city' => $city->getUriIdentity(),
  2454.                 'bodyType' => $bodyType,
  2455.                 'page' => $this->getCurrentPageNumber()
  2456.             ]),
  2457.             'recommendationSpec' => $specs->recommendationSpec(),
  2458.         ], response: $response);
  2459.     }
  2460.     #[ParamConverter("city", converter: "city_converter")]
  2461.     #[Route("/api/profiles/listing/city/{city}/place/{placeType}", name: "api.profile_listing.by_place", methods: "GET", format: "json")]
  2462.     #[Route("/api/profiles/listing/city/{city}/place/{placeType}/{takeOutLocation}", name: "api.profile_listing.by_place.take_out_location", methods: "GET", format: "json")]
  2463.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2464.     #[OA\Tag(name: "ProfileListing")]
  2465.     #[OA\Response(
  2466.         response: 200,
  2467.         description: '',
  2468.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2469.     )]
  2470.     public function listByPlace(Request $request, City $city, string $placeType, string $takeOutLocation = null): Response
  2471.     {
  2472.         if ('take-out' === $placeType && null !== $takeOutLocation && null === TakeOutLocations::getValueByUriIdentity($takeOutLocation)) {
  2473.             throw $this->createNotFoundException();
  2474.         }
  2475.         $specs = $this->profileListSpecificationService->listByPlace($placeType, $takeOutLocation);
  2476.         if (null === $specs) {
  2477.             throw $this->createNotFoundException();
  2478.         }
  2479.         $response = new Response();
  2480.         $alternativeSpec = $this->getORSpecForItemsArray(TakeOutLocations::getList(), function($item): ProfileIsProvidingTakeOut {
  2481.             return new ProfileIsProvidingTakeOut($item);
  2482.         });
  2483.         if ($placeType === 'take-out') {
  2484.             $alternativeSpec->orX(new ProfileHasApartments());
  2485.         }
  2486.         $apiEndpoint = '/city/{city}/place/'.$placeType;
  2487.         if (null !== $takeOutLocation) {
  2488.             $apiEndpoint .= '/'.$takeOutLocation;
  2489.         }
  2490.         $result = $this->paginatedListing($city, $apiEndpoint, ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_BY_PARAMS, $response);
  2491.         if ($this->isApiRequest($request)) {
  2492.             return $this->jsonListingResponse($result, $city, $specs);
  2493.         }
  2494.         return $this->render('ProfileList/list.html.twig', [
  2495.             'profiles' => $result,
  2496.             'source' => $this->source,
  2497.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2498.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2499.                 'city' => $city->getUriIdentity(),
  2500.                 'placeType' => $placeType,
  2501.                 'takeOutLocation' => TakeOutLocations::getUriIdentity(TakeOutLocations::getValueByUriIdentity($takeOutLocation)),
  2502.                 'page' => $this->getCurrentPageNumber()
  2503.             ]),
  2504.             'recommendationSpec' => $specs->recommendationSpec(),
  2505.         ], response: $response);
  2506.     }
  2507.     #[ParamConverter("city", converter: "city_converter")]
  2508.     #[Route("/api/profiles/listing/city/{city}/privatehaircut/{privateHaircut}", name: "api.profile_listing.by_privatehaircut", methods: "GET", format: "json")]
  2509.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2510.     #[OA\Tag(name: "ProfileListing")]
  2511.     #[OA\Response(
  2512.         response: 200,
  2513.         description: '',
  2514.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2515.     )]
  2516.     public function listByPrivateHaircut(Request $request, City $city, string $privateHaircut): Response
  2517.     {
  2518.         if(null === $type = PrivateHaircuts::getValueByUriIdentity($privateHaircut))
  2519.             throw $this->createNotFoundException();
  2520.         $specs = $this->profileListSpecificationService->listByPrivateHaircut($privateHaircut);
  2521.         $response = new Response();
  2522.         $apiEndpoint = '/city/{city}/privatehaircut/'.$type;
  2523.         $alternativeSpec = $this->getORSpecForItemsArray(PrivateHaircuts::getList(), function($item): ProfileWithPrivateHaircut {
  2524.             return new ProfileWithPrivateHaircut($item);
  2525.         });
  2526.         $result = $this->paginatedListing($city, $apiEndpoint, ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_BY_PARAMS, $response);
  2527.         if ($this->isApiRequest($request)) {
  2528.             return $this->jsonListingResponse($result, $city, $specs);
  2529.         }
  2530.         return $this->render('ProfileList/list.html.twig', [
  2531.             'profiles' => $result,
  2532.             'source' => $this->source,
  2533.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2534.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2535.                 'city' => $city->getUriIdentity(),
  2536.                 'privateHaircut' => $privateHaircut,
  2537.                 'page' => $this->getCurrentPageNumber()
  2538.             ]),
  2539.             'recommendationSpec' => $specs->recommendationSpec(),
  2540.         ], response: $response);
  2541.     }
  2542.     #[ParamConverter("city", converter: "city_converter")]
  2543.     #[Route("/api/profiles/listing/city/{city}/nationality/{nationality}", name: "api.profile_listing.by_nationality", methods: "GET", format: "json")]
  2544.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2545.     #[OA\Tag(name: "ProfileListing")]
  2546.     #[OA\Response(
  2547.         response: 200,
  2548.         description: '',
  2549.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2550.     )]
  2551.     public function listByNationality(Request $request, City $city, string $nationality): Response
  2552.     {
  2553.         if (null === $type = Nationalities::getValueByUriIdentity($nationality))
  2554.             throw $this->createNotFoundException();
  2555.         $specs = $this->profileListSpecificationService->listByNationality($nationality);
  2556.         $response = new Response();
  2557.         $alternativeSpec = $this->getORSpecForItemsArray(Nationalities::getList(), function($item): ProfileWithNationality {
  2558.             return new ProfileWithNationality($item);
  2559.         });
  2560.         $apiEndpoint = '/city/{city}/nationality/'.$type;
  2561.         $result = $this->paginatedListing($city, $apiEndpoint, ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_BY_PARAMS, $response);
  2562.         if ($this->isApiRequest($request)) {
  2563.             return $this->jsonListingResponse($result, $city, $specs);
  2564.         }
  2565.         return $this->render('ProfileList/list.html.twig', [
  2566.             'profiles' => $result,
  2567.             'source' => $this->source,
  2568.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2569.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2570.                 'city' => $city->getUriIdentity(),
  2571.                 'nationality' => $nationality,
  2572.                 'page' => $this->getCurrentPageNumber()
  2573.             ]),
  2574.             'recommendationSpec' => $specs->recommendationSpec(),
  2575.         ], response: $response);
  2576.     }
  2577.     #[ParamConverter("city", converter: "city_converter")]
  2578.     #[Route("/api/profiles/listing/city/{city}/appearance/{appearance}", name: "api.profile_listing.by_appearance", methods: "GET", format: "json")]
  2579.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2580.     #[OA\Tag(name: "ProfileListing")]
  2581.     #[OA\Response(
  2582.         response: 200,
  2583.         description: '',
  2584.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2585.     )]
  2586.     public function listByAppearance(Request $request, City $city, string $appearance): Response
  2587.     {
  2588.         if (null === $type = Appearances::getValueByUriIdentity($appearance))
  2589.             throw $this->createNotFoundException();
  2590.         $specs = $this->profileListSpecificationService->listByAppearance($appearance);
  2591.         $response = new Response();
  2592.         $alternativeSpec = $this->getORSpecForItemsArray(Appearances::getList(), function($item): ProfileWithAppearance {
  2593.             return new ProfileWithAppearance($item);
  2594.         });
  2595.         $apiEndpoint = '/city/{city}/appearance/'.$type;
  2596.         $result = $this->paginatedListing($city, $apiEndpoint, ['city' => $city->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_BY_PARAMS, $response);
  2597.         if ($this->isApiRequest($request)) {
  2598.             return $this->json($result);
  2599.         }
  2600.         return $this->render('ProfileList/list.html.twig', [
  2601.             'profiles' => $result,
  2602.             'source' => $this->source,
  2603.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2604.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2605.                 'city' => $city->getUriIdentity(),
  2606.                 'appearance' => $appearance,
  2607.                 'page' => $this->getCurrentPageNumber()
  2608.             ]),
  2609.             'recommendationSpec' => $specs->recommendationSpec(),
  2610.         ], response: $response);
  2611.     }
  2612.     #[ParamConverter("city", converter: "city_converter")]
  2613.     #[ParamConverter("service", options: ['mapping' => ['service' => 'uriIdentity']])]
  2614.     #[Route("/api/profiles/listing/city/{city}/service/{service}", name: "api.profile_listing.by_service", methods: "GET", format: "json")]
  2615.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2616.     #[OA\Tag(name: "ProfileListing")]
  2617.     #[OA\Response(
  2618.         response: 200,
  2619.         description: '',
  2620.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2621.     )]
  2622.     public function listByProvidedService(Request $request, City $city, Service $service): Response
  2623.     {
  2624.         $specs = $this->profileListSpecificationService->listByProvidedService($service, $city);
  2625.         $response = new Response();
  2626.         $sameGroupServices = $this->serviceRepository->findBy(['group' => $service->getGroup()]);
  2627.         $alternativeSpec = $this->getORSpecForItemsArray([$sameGroupServices], function($item): ProfileIsProvidingOneOfServices {
  2628.             return new ProfileIsProvidingOneOfServices($item);
  2629.         });
  2630.         $result = $this->paginatedListing($city, '/city/{city}/service/{service}', ['city' => $city->getId(), 'service' => $service->getId()], $specs->spec(), $alternativeSpec, self::RESULT_SOURCE_SERVICE, $response);
  2631.         if ($this->isApiRequest($request)) {
  2632.             return $this->jsonListingResponse($result, $city, $specs);
  2633.         }
  2634.         return $this->render('ProfileList/list.html.twig', [
  2635.             'profiles' => $result,
  2636.             'source' => $this->source,
  2637.             'source_default' => self::RESULT_SOURCE_SERVICE,
  2638.             'service' => $service,
  2639.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2640.                 'city' => $city->getUriIdentity(),
  2641.                 'service' => $service->getUriIdentity(),
  2642.                 'page' => $this->getCurrentPageNumber()
  2643.             ]),
  2644.             'recommendationSpec' => $specs->recommendationSpec(),
  2645.         ], response: $response);
  2646.     }
  2647.     #[ParamConverter("city", converter: "city_converter")]
  2648.     #[ParamConverter("item", options: ['mapping' => ['item' => 'uriIdentity']])]
  2649.     #[Route("/api/profiles/listing/city/{city}/inventory-item/{item}", name: "api.profile_listing.by_inventory_item", methods: "GET", format: "json")]
  2650.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2651.     #[OA\Tag(name: "ProfileListing")]
  2652.     #[OA\Response(
  2653.         response: 200,
  2654.         description: '',
  2655.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2656.     )]
  2657.     public function listByInventoryItem(Request $request, City $city, ProfileInventoryItem $item): Response
  2658.     {
  2659.         if (!$this->isInventoryItemTypeEnabled($item)) {
  2660.             throw $this->createNotFoundException();
  2661.         }
  2662.         $specs = $this->profileListSpecificationService->listByInventoryItem($item);
  2663.         $response = new Response();
  2664.         $result = $this->paginatedListing($city, '/city/{city}/inventory-item/{item}', ['city' => $city->getId(), 'item' => $item->getId()], $specs->spec(), null, self::RESULT_SOURCE_PROFILE_INVENTORY_ITEM, $response);
  2665.         $request->attributes->set('profiles_count', $result->totalCount());
  2666.         if ($this->isApiRequest($request)) {
  2667.             return $this->json($result);
  2668.         }
  2669.         return $this->render('ProfileList/list.html.twig', [
  2670.             'profiles' => $result,
  2671.             'source' => $this->source,
  2672.             'source_default' => self::RESULT_SOURCE_PROFILE_INVENTORY_ITEM,
  2673.             'inventory_item' => $item,
  2674.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2675.                 'city' => $city->getUriIdentity(),
  2676.                 'item' => $item->getUriIdentity(),
  2677.                 'page' => $this->getCurrentPageNumber()
  2678.             ]),
  2679.             'recommendationSpec' => $specs->recommendationSpec(),
  2680.         ], response: $response);
  2681.     }
  2682.     private function isInventoryItemTypeEnabled(ProfileInventoryItem $item): bool
  2683.     {
  2684.         return match ($item->getType()) {
  2685.             ProfileInventoryItemType::SEX_TOY => $this->features->sex_toys(),
  2686.             ProfileInventoryItemType::CLOTHES_AND_UNDERWEAR => $this->features->clothes_and_underwear(),
  2687.             ProfileInventoryItemType::ROLE_PLAYING_COSTUME => $this->features->role_playing_costumes(),
  2688.             default => false,
  2689.         };
  2690.     }
  2691.     /**
  2692.      * @Feature("list_names")
  2693.      */
  2694.     #[ParamConverter("city", converter: "city_converter")]
  2695.     #[Route("/api/profiles/listing/city/{city}/names", name: "api.profile_listing.names", methods: "GET", format: "json")]
  2696.     #[OA\Tag(name: "ProfileListing")]
  2697.     #[OA\Response(
  2698.         response: 200,
  2699.         description: 'Список имен анкет по городу',
  2700.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileNamesPage")
  2701.     )]
  2702.     #[Cache(maxage: 3600, public: true)]
  2703.     public function listNames(Request $request, City $city): Response
  2704.     {
  2705.         $names = $this->profileNameLandingProvider->groupedNamesByCity($city);
  2706.         $popularNames = $this->profileNameLandingProvider->popularNamesByCity($city);
  2707.         if ($this->isApiRequest($request)) {
  2708.             return $this->json([
  2709.                 'data' => $names,
  2710.                 'popularNames' => $popularNames,
  2711.             ]);
  2712.         }
  2713.         return parent::render('ProfileNameList/list.html.twig', [
  2714.             'names' => $names,
  2715.             'popularNames' => $popularNames,
  2716.         ]);
  2717.     }
  2718.     /**
  2719.      * @Feature("list_names")
  2720.      */
  2721.     #[ParamConverter("city", converter: "city_converter")]
  2722.     #[Route("/api/profiles/listing/city/{city}/name/{name}", name: "api.profile_listing.by_name", methods: "GET", format: "json")]
  2723.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2724.     #[OA\Tag(name: "ProfileListing")]
  2725.     #[OA\Response(
  2726.         response: 200,
  2727.         description: 'Листинг анкет по имени',
  2728.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileNameListingPage")
  2729.     )]
  2730.     #[Cache(maxage: 3600, public: true)]
  2731.     public function listByName(Request $request, City $city, string $name): Response
  2732.     {
  2733.         $profileName = $this->profileNameLandingProvider->findNameByUri($city, $name);
  2734.         if (null === $profileName) {
  2735.             throw $this->createNotFoundException();
  2736.         }
  2737.         $request->attributes->set('profileName', $profileName);
  2738.         $specs = new ProfileListSpecification(new ProfileIdIn($profileName['profileIds']), null);
  2739.         $response = new Response();
  2740.         $result = $this->paginatedListing(
  2741.             $city,
  2742.             '/city/{city}/name/{name}',
  2743.             ['city' => $city->getId(), 'name' => $profileName['uriIdentity']],
  2744.             $specs->spec(),
  2745.             null,
  2746.             null,
  2747.             $response
  2748.         );
  2749.         $response->setMaxAge(3600);
  2750.         if ($this->isApiRequest($request)) {
  2751.             return $this->jsonListingResponse($result, $city, $specs, [
  2752.                 'popularNames' => $this->profileNameLandingProvider->popularNamesByCity($city),
  2753.             ]);
  2754.         }
  2755.         return $this->render('ProfileNameList/by_name.html.twig', [
  2756.             'profiles' => $result,
  2757.             'profileName' => $profileName,
  2758.             'popularNames' => $this->profileNameLandingProvider->popularNamesByCity($city),
  2759.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2760.                 'city' => $city->getUriIdentity(),
  2761.                 'name' => $profileName['uriIdentity'],
  2762.                 'page' => $this->getCurrentPageNumber(),
  2763.             ]),
  2764.             'recommendationSpec' => $specs->recommendationSpec(),
  2765.         ], response: $response);
  2766.     }
  2767.     /**
  2768.      * @Feature("has_archive_page")
  2769.      */
  2770.     #[ParamConverter("city", converter: "city_converter")]
  2771.     #[Route("/api/profiles/listing/city/{city}/archive", name: "api.profile_listing.archive", methods: "GET", format: "json")]
  2772.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2773.     #[OA\Tag(name: "ProfileListing")]
  2774.     #[OA\Response(
  2775.         response: 200,
  2776.         description: '',
  2777.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2778.     )]
  2779.     public function listArchived(Request $request, City $city): Response
  2780.     {
  2781.         $result = $this->profileList->list($city, null, null, null, false, null, ProfileList::ORDER_BY_UPDATED);
  2782.         if ($this->isApiRequest($request)) {
  2783.             return $this->jsonListingResponse($result, $city, null);
  2784.         }
  2785.         return $this->render('ProfileList/list.html.twig', [
  2786.             'profiles' => $result,
  2787.             'recommendationSpec' => new \App\Specification\ElasticSearch\ProfileIsNotArchived(), //ProfileIsArchived, согласно https://redminez.net/issues/28305 в реках выводятся неарзивные
  2788.         ]);
  2789.     }
  2790.     #[ParamConverter("city", converter: "city_converter")]
  2791.     #[Route("/api/profiles/listing/city/{city}/recent", name: "api.profile_listing.recent", methods: "GET", format: "json")]
  2792.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2793.     #[OA\Tag(name: "ProfileListing")]
  2794.     #[OA\Response(
  2795.         response: 200,
  2796.         description: '',
  2797.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2798.     )]
  2799.     public function listNew(Request $request, City $city, int $weeks = 2): Response
  2800.     {
  2801.         $specs = $this->profileListSpecificationService->listNew($weeks);
  2802.         $response = new Response();
  2803.         $result = $this->profileList->listLatestCreated(
  2804.             $city,
  2805.             self::NEW_PROFILES_LIMIT,
  2806.             withinCity: !$this->mixedCityListings->omitCityOnProfileFallback('/city/{city}/recent'),
  2807.         );
  2808.         if ($this->isApiRequest($request)) {
  2809.             return $this->jsonListingResponse($result, $city, $specs);
  2810.         }
  2811.         return $this->render('ProfileList/list.html.twig', [
  2812.             'profiles' => $result,
  2813.             'recommendationSpec' => $specs->recommendationSpec(),
  2814.         ], response: $response);
  2815.     }
  2816.     #[ParamConverter("city", converter: "city_converter")]
  2817.     #[Route("/api/profiles/listing/city/{city}/noretouch", name: "api.profile_listing.noretouch", methods: "GET", format: "json")]
  2818.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2819.     #[OA\Tag(name: "ProfileListing")]
  2820.     #[OA\Response(
  2821.         response: 200,
  2822.         description: '',
  2823.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2824.     )]
  2825.     public function listByNoRetouch(Request $request, City $city): Response
  2826.     {
  2827.         $specs = $this->profileListSpecificationService->listByNoRetouch();
  2828.         $response = new Response();
  2829.         $result = $this->paginatedListing($city, '/city/{city}/noretouch', ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  2830.         if ($this->isApiRequest($request)) {
  2831.             return $this->jsonListingResponse($result, $city, $specs);
  2832.         }
  2833.         return $this->render('ProfileList/list.html.twig', [
  2834.             'profiles' => $result,
  2835.             'profiles_count' => $result->count(),
  2836.             'source' => $this->source,
  2837.             'recommendationSpec' => $specs->recommendationSpec(),
  2838.         ], response: $response);
  2839.     }
  2840.     #[ParamConverter("city", converter: "city_converter")]
  2841.     #[Route("/api/profiles/listing/city/{city}/nice", name: "api.profile_listing.nice", methods: "GET", format: "json")]
  2842.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2843.     #[OA\Tag(name: "ProfileListing")]
  2844.     #[OA\Response(
  2845.         response: 200,
  2846.         description: '',
  2847.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2848.     )]
  2849.     public function listByNice(Request $request, City $city): Response
  2850.     {
  2851.         $specs = $this->profileListSpecificationService->listByNice();
  2852.         $response = new Response();
  2853.         $result = $this->paginatedListing($city, '/city/{city}/nice', ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  2854.         if ($this->isApiRequest($request)) {
  2855.             return $this->jsonListingResponse($result, $city, $specs);
  2856.         }
  2857.         return $this->render('ProfileList/list.html.twig', [
  2858.             'profiles' => $result,
  2859.             'source' => $this->source,
  2860.             'recommendationSpec' => $specs->recommendationSpec(),
  2861.         ], response: $response);
  2862.     }
  2863.     #[ParamConverter("city", converter: "city_converter")]
  2864.     #[Route("/api/profiles/listing/city/{city}/oncall", name: "api.profile_listing.oncall", methods: "GET", format: "json")]
  2865.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2866.     #[OA\Tag(name: "ProfileListing")]
  2867.     #[OA\Response(
  2868.         response: 200,
  2869.         description: '',
  2870.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2871.     )]
  2872.     public function listByOnCall(Request $request, City $city): Response
  2873.     {
  2874.         $specs = $this->profileListSpecificationService->listByOnCall();
  2875.         $response = new Response();
  2876.         $result = $this->paginatedListing($city, '/city/{city}/oncall', ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  2877.         if ($this->isApiRequest($request)) {
  2878.             return $this->jsonListingResponse($result, $city, $specs);
  2879.         }
  2880.         return $this->render('ProfileList/list.html.twig', [
  2881.             'profiles' => $result,
  2882.             'source' => $this->source,
  2883.             'recommendationSpec' => $specs->recommendationSpec(),
  2884.         ], response: $response);
  2885.     }
  2886.     #[ParamConverter("city", converter: "city_converter")]
  2887.     #[Route("/api/profiles/listing/city/{city}/fornight", name: "api.profile_listing.fornight", methods: "GET", format: "json")]
  2888.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2889.     #[OA\Tag(name: "ProfileListing")]
  2890.     #[OA\Response(
  2891.         response: 200,
  2892.         description: '',
  2893.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2894.     )]
  2895.     public function listForNight(Request $request, City $city): Response
  2896.     {
  2897.         $specs = $this->profileListSpecificationService->listForNight();
  2898.         $response = new Response();
  2899.         $result = $this->paginatedListing($city, '/city/{city}/fornight', ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  2900.         if ($this->isApiRequest($request)) {
  2901.             return $this->jsonListingResponse($result, $city, $specs);
  2902.         }
  2903.         return $this->render('ProfileList/list.html.twig', [
  2904.             'profiles' => $result,
  2905.             'source' => $this->source,
  2906.             'recommendationSpec' => $specs->recommendationSpec(),
  2907.         ], response: $response);
  2908.     }
  2909.     private function getSpecForEliteGirls(City $city): Filter
  2910.     {
  2911.         $minPrice = $this->countryCurrencyResolver->getValueByCountryCode($city->getCountryCode(), [
  2912.             'RUB' => 5000,
  2913.             'UAH' => 1500,
  2914.             'USD' => 100,
  2915.             'EUR' => 130,
  2916.         ]);
  2917.         return new ProfileIsElite($minPrice);
  2918.     }
  2919.     private function getElasticSearchSpecForEliteGirls(City $city): ISpecification
  2920.     {
  2921.         $minPrice = $this->countryCurrencyResolver->getValueByCountryCode($city->getCountryCode(), [
  2922.             'RUB' => 5000,
  2923.             'UAH' => 1500,
  2924.             'USD' => 100,
  2925.             'EUR' => 130,
  2926.         ]);
  2927.         return new \App\Specification\ElasticSearch\ProfileIsElite($minPrice);
  2928.     }
  2929.     #[ParamConverter("city", converter: "city_converter")]
  2930.     #[Route("/api/profiles/listing/city/{city}/elite", name: "api.profile_listing.elite", methods: "GET", format: "json")]
  2931.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2932.     #[OA\Tag(name: "ProfileListing")]
  2933.     #[OA\Response(
  2934.         response: 200,
  2935.         description: '',
  2936.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2937.     )]
  2938.     public function listForEliteGirls(CountryCurrencyResolver $countryCurrencyResolver, Request $request, City $city): Response
  2939.     {
  2940.         $specs = $this->profileListSpecificationService->listForEliteGirls($city);
  2941.         $response = new Response();
  2942.         $result = $this->paginatedListing($city, '/city/{city}/elite', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  2943.         if ($this->isApiRequest($request)) {
  2944.             return $this->jsonListingResponse($result, $city, $specs);
  2945.         }
  2946.         return $this->render('ProfileList/list.html.twig', [
  2947.             'profiles' => $result,
  2948.             'source' => $this->source,
  2949.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  2950.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  2951.                 'city' => $city->getUriIdentity(),
  2952.                 'page' => $this->getCurrentPageNumber()
  2953.             ]),
  2954.             'recommendationSpec' => $specs->recommendationSpec(),
  2955.         ], response: $response);
  2956.     }
  2957.     #[ParamConverter("city", converter: "city_converter")]
  2958.     #[Route("/api/profiles/listing/city/{city}/realelite", name: "api.profile_listing.real_elite", methods: "GET", format: "json")]
  2959.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2960.     #[OA\Tag(name: "ProfileListing")]
  2961.     #[OA\Response(
  2962.         response: 200,
  2963.         description: '',
  2964.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2965.     )]
  2966.     public function listForRealElite(Request $request, CountryCurrencyResolver $countryCurrencyResolver, City $city): Response
  2967.     {
  2968.         $specs = $this->profileListSpecificationService->listForRealElite($city);
  2969.         $response = new Response();
  2970.         $result = $this->paginatedListing($city, '/city/{city}/realelite', ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  2971.         if ($this->isApiRequest($request)) {
  2972.             return $this->jsonListingResponse($result, $city, $specs);
  2973.         }
  2974.         return $this->render('ProfileList/list.html.twig', [
  2975.             'profiles' => $result,
  2976.             'source' => $this->source,
  2977.             'recommendationSpec' => $specs->recommendationSpec(),
  2978.         ], response: $response);
  2979.     }
  2980.     #[ParamConverter("city", converter: "city_converter")]
  2981.     #[Route("/api/profiles/listing/city/{city}/vip", name: "api.profile_listing.vip", methods: "GET", format: "json")]
  2982.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  2983.     #[OA\Tag(name: "ProfileListing")]
  2984.     #[OA\Response(
  2985.         response: 200,
  2986.         description: '',
  2987.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  2988.     )]
  2989.     public function listForVipPros(Request $request, CountryCurrencyResolver $countryCurrencyResolver, City $city): Response
  2990.     {
  2991.         $specs = $this->profileListSpecificationService->listForVipPros($city);
  2992.         $response = new Response();
  2993.         $result = $this->paginatedListing($city, '/city/{city}/vip', ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  2994.         if ($this->isApiRequest($request)) {
  2995.             return $this->jsonListingResponse($result, $city, $specs);
  2996.         }
  2997.         return $this->render('ProfileList/list.html.twig', [
  2998.             'profiles' => $result,
  2999.             'source' => $this->source,
  3000.             'recommendationSpec' => $specs->recommendationSpec(),
  3001.         ], response: $response);
  3002.     }
  3003.     #[ParamConverter("city", converter: "city_converter")]
  3004.     #[Route("/api/profiles/listing/city/{city}/vipindi", name: "api.profile_listing.vipindi", methods: "GET", format: "json")]
  3005.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  3006.     #[OA\Tag(name: "ProfileListing")]
  3007.     #[OA\Response(
  3008.         response: 200,
  3009.         description: '',
  3010.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  3011.     )]
  3012.     public function listForVipIndividual(Request $request, CountryCurrencyResolver $countryCurrencyResolver, City $city): Response
  3013.     {
  3014.         $specs = $this->profileListSpecificationService->listForVipIndividual($city);
  3015.         $response = new Response();
  3016.         $result = $this->paginatedListing($city, '/city/{city}/vipindi', ['city' => $city->getId()], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  3017.         if ($this->isApiRequest($request)) {
  3018.             return $this->jsonListingResponse($result, $city, $specs);
  3019.         }
  3020.         return $this->render('ProfileList/list.html.twig', [
  3021.             'profiles' => $result,
  3022.             'source' => $this->source,
  3023.             'recommendationSpec' => $specs->recommendationSpec(),
  3024.         ], response: $response);
  3025.     }
  3026.     #[ParamConverter("city", converter: "city_converter")]
  3027.     #[Route("/api/profiles/listing/city/{city}/vipgirls", name: "api.profile_listing.vipgirls", methods: "GET", format: "json")]
  3028.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  3029.     #[OA\Tag(name: "ProfileListing")]
  3030.     #[OA\Response(
  3031.         response: 200,
  3032.         description: '',
  3033.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  3034.     )]
  3035.     public function listForVipGirlsCity(Request $request, City $city): Response
  3036.     {
  3037.         $specs = $this->profileListSpecificationService->listForVipGirlsCity($city);
  3038.         $response = new Response();
  3039.         $result = $this->paginatedListing($city, null, [], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  3040.         if ($this->isApiRequest($request)) {
  3041.             return $this->jsonListingResponse($result, $city, $specs);
  3042.         }
  3043.         return $this->render('ProfileList/list.html.twig', [
  3044.             'profiles' => $result,
  3045.             'source' => $this->source,
  3046.             'recommendationSpec' => $specs->recommendationSpec(),
  3047.         ], response: $response);
  3048.     }
  3049.     #[ParamConverter("city", converter: "city_converter")]
  3050.     #[Route("/api/profiles/listing/city/{city}/girlfriends", name: "api.profile_listing.girlfriends", methods: "GET", format: "json")]
  3051.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  3052.     #[OA\Tag(name: "ProfileListing")]
  3053.     #[OA\Response(
  3054.         response: 200,
  3055.         description: '',
  3056.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  3057.     )]
  3058.     public function listOfGirlfriends(Request $request, City $city): Response
  3059.     {
  3060.         $specs = $this->profileListSpecificationService->listOfGirlfriends();
  3061.         $response = new Response();
  3062.         $result = $this->paginatedListing($city, null, [], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  3063.         if ($this->isApiRequest($request)) {
  3064.             return $this->jsonListingResponse($result, $city, $specs);
  3065.         }
  3066.         return $this->render('ProfileList/list.html.twig', [
  3067.             'profiles' => $result,
  3068.             'source' => $this->source,
  3069.             'recommendationSpec' => $specs->recommendationSpec(),
  3070.         ]);
  3071.     }
  3072.     #[ParamConverter("city", converter: "city_converter")]
  3073.     #[Route("/api/profiles/listing/city/{city}/most_expensive", name: "api.profile_listing.most_expensive", methods: "GET", format: "json")]
  3074.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  3075.     #[OA\Tag(name: "ProfileListing")]
  3076.     #[OA\Response(
  3077.         response: 200,
  3078.         description: '',
  3079.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  3080.     )]
  3081.     public function listOfMostExpensive(Request $request, City $city): Response
  3082.     {
  3083.         $specs = $this->profileListSpecificationService->listOfMostExpensive($city);
  3084.         $response = new Response();
  3085.         $result = $this->paginatedListing($city, null, [], $specs->spec(), null, self::RESULT_SOURCE_CITY, $response);
  3086.         if ($this->isApiRequest($request)) {
  3087.             return $this->jsonListingResponse($result, $city, $specs);
  3088.         }
  3089.         return $this->render('ProfileList/list.html.twig', [
  3090.             'profiles' => $result,
  3091.             'source' => $this->source,
  3092.             'recommendationSpec' => $specs->recommendationSpec(),
  3093.         ]);
  3094.     }
  3095.     #[ParamConverter("city", converter: "city_converter")]
  3096.     #[Route("/api/profiles/listing/city/{city}/bdsm", name: "api.profile_listing.bdsm", methods: "GET", format: "json")]
  3097.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  3098.     #[OA\Tag(name: "ProfileListing")]
  3099.     #[OA\Response(
  3100.         response: 200,
  3101.         description: '',
  3102.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  3103.     )]
  3104.     public function listBdsm(Request $request, City $city, ServiceRepository $serviceRepository, ParameterBagInterface $parameterBag): Response
  3105.     {
  3106.         $specs = $this->profileListSpecificationService->listBdsm();
  3107.         $response = new Response();
  3108.         $result = $this->paginatedListing($city, '/city/{city}/bdsm', ['city' => $city->getId()], $specs->spec(), null, null, $response);
  3109.         if ($this->isApiRequest($request)) {
  3110.             return $this->jsonListingResponse($result, $city, $specs);
  3111.         }
  3112.         return $this->render('ProfileList/list.html.twig', [
  3113.             'profiles' => $result,
  3114.             'recommendationSpec' => $specs->recommendationSpec(),
  3115.         ], response: $response);
  3116.     }
  3117.     #[ParamConverter("city", converter: "city_converter")]
  3118.     #[Route("/api/profiles/listing/city/{city}/gender/{gender}", name: "api.profile_listing.by_gender", methods: "GET", format: "json")]
  3119.     #[OA\Parameter(name: "page", in: "query", schema: new OA\Schema(type: "integer", default: 1, minimum: 1))]
  3120.     #[OA\Tag(name: "ProfileListing")]
  3121.     #[OA\Response(
  3122.         response: 200,
  3123.         description: '',
  3124.         content: new OA\JsonContent(ref: "#/components/schemas/ProfileListingPage")
  3125.     )]
  3126.     public function listByGender(Request $request, City $city, string $gender, DefaultCityProvider $defaultCityProvider): Response
  3127.     {
  3128.         if ($city->getId() != $defaultCityProvider->getDefaultCity()->getId()) {
  3129.             throw $this->createNotFoundException();
  3130.         }
  3131.         if (null === Genders::getValueByUriIdentity($gender))
  3132.             throw $this->createNotFoundException();
  3133.         $specs = $this->profileListSpecificationService->listByGender($gender);
  3134.         $response = new Response();
  3135.         $result = $this->paginatedListing($city, null, [], $specs->spec(), null, null, $response);
  3136.         if ($this->isApiRequest($request)) {
  3137.             return $this->jsonListingResponse($result, $city, $specs);
  3138.         }
  3139.         return $this->render('ProfileList/list.html.twig', [
  3140.             'profiles' => $result,
  3141.             'recommendationSpec' => $specs->recommendationSpec(),
  3142.         ]);
  3143.     }
  3144.     /**
  3145.      * Сейчас не используется, решили доставать их всех соседних подкатегорий разом.
  3146.      * Пока оставил, вдруг передумают.
  3147.      * @deprecated
  3148.      */
  3149.     public function listByNextSimilarCategories(callable $listMethod, $requestCategory, array $similarItems): ORMQueryResult
  3150.     {
  3151.         $similarItems = array_filter($similarItems, function ($item) use ($requestCategory): bool {
  3152.             return $item != $requestCategory;
  3153.         });
  3154.         //shuffle($similarItems);
  3155.         $item = null;
  3156.         $result = null;
  3157.         do {
  3158.             $item = $item == null ? current($similarItems) : next($similarItems);
  3159.             if (false === $item)
  3160.                 return $result;
  3161.             $result = $listMethod($item);
  3162.         } while ($result->count() == 0);
  3163.         return $result;
  3164.     }
  3165.     private function shouldShowHomepageCityListingsBlock(City $city, int $page, bool $subRequest): bool
  3166.     {
  3167.         if ($page !== 1) {
  3168.             return false;
  3169.         }
  3170.         if ($subRequest) {
  3171.             return true;
  3172.         }
  3173.         return !$city->equals($this->parameterBag->get('default_city'));
  3174.     }
  3175.     protected function getCurrentPageNumber(): int
  3176.     {
  3177.         $page = (int) $this->requestStack->getCurrentRequest()?->get($this->pageParameter, 1);
  3178.         if ($page < 1) {
  3179.             $page = 1;
  3180.         }
  3181.         return $page;
  3182.     }
  3183.     protected function render(string $view, array $parameters = [], Response $response = null): Response
  3184.     {
  3185.         $skipListingRecommendations = !empty($parameters['skip_listing_recommendations']);
  3186.         if (!$skipListingRecommendations) {
  3187.             $parameters = $this->fillListingWithRecommendations($parameters);
  3188.         }
  3189.         $this->listingService->setCurrentListingPage($parameters['profiles']);
  3190.         $requestAttrs = $this->requestStack->getCurrentRequest();
  3191.         if (isset($parameters['profiles']) && is_object($parameters['profiles']) && method_exists($parameters['profiles'], 'totalCount')) {
  3192.             $profilesCount = $parameters['profiles']->totalCount();
  3193.             $requestAttrs->attributes->set('profiles_count', $profilesCount);
  3194.             $this->requestStack->getMainRequest()?->attributes->set('profiles_count', $profilesCount);
  3195.         }
  3196.         $listing = $parameters['listing'] ?? $requestAttrs->get('_controller');
  3197.         $listing = is_array($listing) ? $listing[count($listing) - 1] : $listing;
  3198.         $listing = preg_replace('/[^:]+::/', '', $listing);
  3199.         $listingParameters = $requestAttrs->get('_route_params');
  3200.         $listingParameters = is_array($listingParameters) ? $listingParameters : [];
  3201.         $mainRequestHasPageParam = isset(($this->requestStack->getMainRequest()->get('_route_params') ?? [])['page']);
  3202.         if ($this->requestStack->getCurrentRequest()->isXmlHttpRequest()) {
  3203.             $view = (
  3204.                 str_starts_with($listing, 'list')
  3205.                 && 'ProfileList/list.html.twig' === $view
  3206.                 && $mainRequestHasPageParam //isset($listingParameters['page'])
  3207.             )
  3208.                 ? 'ProfileList/list.profiles.html.twig'
  3209.                 : $view;
  3210.             return $this->prepareForXhr(parent::render($view, $parameters, $response));
  3211.             //return $this->getJSONResponse($parameters);
  3212.         } else {
  3213.             if (!$skipListingRecommendations) {
  3214.                 $parameters = $this->prepareSsrRecommendedProfiles($parameters);
  3215.             }
  3216.             $parameters = array_merge($parameters, [
  3217.                 'listing' => $listing,
  3218.                 'listing_parameters' => $listingParameters,
  3219.             ]);
  3220.             return parent::render($view, $parameters, $response);
  3221.         }
  3222.     }
  3223.     private function fillListingWithRecommendations(array $parameters): array
  3224.     {
  3225.         $parameters['recommendations_fill_applied'] = $parameters['recommendations_fill_applied'] ?? false;
  3226.         if (!($parameters['profiles'] ?? null) instanceof Page) {
  3227.             return $parameters;
  3228.         }
  3229.         $city = $this->requestStack->getCurrentRequest()?->attributes->get('city');
  3230.         if (!$city instanceof City) {
  3231.             return $parameters;
  3232.         }
  3233.         $filled = $this->profileListingRecommendationsFiller->fill(
  3234.             $city,
  3235.             $parameters['profiles'],
  3236.             $this->resolveRecommendationGenders(),
  3237.         );
  3238.         $parameters['profiles'] = $filled['profiles'];
  3239.         $parameters['recommendations_fill_applied'] = $filled['applied'];
  3240.         $parameters['recommendations_fill_original_count'] = $filled['original_count'];
  3241.         $parameters['excludeRecommendationProfileIds'] = array_values(array_unique(array_merge(
  3242.             $parameters['excludeRecommendationProfileIds'] ?? [],
  3243.             $filled['visible_profile_ids'] ?? [],
  3244.         )));
  3245.         return $parameters;
  3246.     }
  3247.     private function prepareSsrRecommendedProfiles(array $parameters): array
  3248.     {
  3249.         if (!empty($parameters['recommendations_fill_applied'])) {
  3250.             return $parameters;
  3251.         }
  3252.         if (isset($parameters['ssr_recommended_profiles']) || !($parameters['profiles'] ?? null) instanceof Page) {
  3253.             return $parameters;
  3254.         }
  3255.         $city = $this->requestStack->getCurrentRequest()?->attributes->get('city');
  3256.         if (!$city instanceof City) {
  3257.             return $parameters;
  3258.         }
  3259.         $parameters['ssr_recommended_profiles'] = $this->profileListingRecommendationsFiller->popularProfilesForBlock(
  3260.             $city,
  3261.             $parameters['profiles'],
  3262.             $this->resolveRecommendationGenders(),
  3263.             5,
  3264.             $parameters['excludeRecommendationProfileIds'] ?? [],
  3265.         );
  3266.         return $parameters;
  3267.     }
  3268.     private function resolveRecommendationGenders(): array
  3269.     {
  3270.         $gender = $this->requestStack->getCurrentRequest()?->attributes->get('gender');
  3271.         if (is_string($gender) && null !== Genders::getValueByUriIdentity($gender)) {
  3272.             return [Genders::getValueByUriIdentity($gender)];
  3273.         }
  3274.         return [Genders::FEMALE];
  3275.     }
  3276.     private function listActiveWithinCityOrderedByStatusWithSpecAvoidingTopPlacementLimited(
  3277.         City $city,
  3278.         ?Filter $spec,
  3279.         array $additionalSpecs = null,
  3280.         array $genders = [Genders::FEMALE],
  3281.         int $limit = 0,
  3282.     ): array|Page {
  3283.         return $this->profileList->listActiveWithinCityOrderedByStatusWithSpecLimited($city, $spec, $additionalSpecs, $genders, true, $limit);
  3284.     }
  3285.     private function listRandomSinglePage(
  3286.         City $city,
  3287.         ?string $country,
  3288.         ?Filter $spec,
  3289.         ?array $additionalSpecs,
  3290.         bool $active,
  3291.         ?bool $masseur = false,
  3292.         array $genders = [Genders::FEMALE]
  3293.     ): Page {
  3294.         return $this->profileList->listRandom($city, $country, $spec, $additionalSpecs, $active, $masseur, $genders, true);
  3295.     }
  3296.     private function shuffleProfilesOnPage(Page $result): Page
  3297.     {
  3298.         $profiles = iterator_to_array($result->getIterator());
  3299.         if(count($profiles) > 1) {
  3300.             shuffle($profiles);
  3301.         }
  3302.         return new FakeORMQueryPage(
  3303.             $result->getCurrentOffset(),
  3304.             $result->getCurrentPage(),
  3305.             $result->getCurrentLimit(),
  3306.             $result->totalCount(),
  3307.             $profiles
  3308.         );
  3309.     }
  3310.     /**
  3311.      * Достает из списка анкет их id с учетом совместимости разных форматов данных
  3312.      */
  3313.     private function extractProfileIds(array $profiles): array
  3314.     {
  3315.         $ids = array_map(static function ($item) {
  3316.             /**
  3317.              * - array - данные из микросервиса ротации через API
  3318.              * - Profile::getId() - полноценная сущность анкеты
  3319.              * - ProfileListingReadModel::$id - read-model анкеты
  3320.              */
  3321.             return is_array($item) ? $item['id'] : ($item?->id ?? $item?->getId());
  3322.         }, $profiles);
  3323.         return array_filter($ids); // remove null values
  3324.     }
  3325. //    protected function getJSONResponse(array $parameters)
  3326. //    {
  3327. //        $request = $this->request;
  3328. //        $data = json_decode($request->getContent(), true);
  3329. //
  3330. //        $imageSize = !empty($data['imageSize']) ? $data['imageSize'] : "357x500";
  3331. //
  3332. //        /** @var FakeORMQueryPage $queryPage */
  3333. //        $queryPage = $parameters['profiles'];
  3334. //
  3335. //        $profiles = array_map(function(ProfileListingReadModel $profile) use ($imageSize) {
  3336. //            $profile->stations = array_values($profile->stations);
  3337. //            $profile->avatar['path'] = $this->responsiveAssetsService->getResponsiveImageUrl($profile->avatar['path'], 'profile_media', $imageSize, 'jpg');
  3338. //            $profile->uri = $this->generateUrl('profile_preview.page', ['city' => $profile->city->uriIdentity, 'profile' => $profile->uriIdentity]);
  3339. //            return $profile;
  3340. //        }, $queryPage->getArray());
  3341. //
  3342. //        return new JsonResponse([
  3343. //            'profiles' => $profiles,
  3344. //            'currentPage' => $queryPage->getCurrentPage(),
  3345. //        ], Response::HTTP_OK);
  3346. //    }
  3347. }