src/Controller/ProfileListController.php line 1877

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\Bridge\Porpaginas\Doctrine\ORM\FakeORMQueryPage;
  9. use App\Entity\Location\City;
  10. use App\Entity\Location\County;
  11. use App\Entity\Location\District;
  12. use App\Entity\Location\Station;
  13. use App\Entity\Profile\BodyTypes;
  14. use App\Entity\Profile\BreastTypes;
  15. use App\Entity\Profile\Genders;
  16. use App\Entity\Profile\HairColors;
  17. use App\Entity\Profile\Nationalities;
  18. use App\Entity\Profile\PrivateHaircuts;
  19. use App\Entity\Service;
  20. use App\Entity\ServiceGroups;
  21. use App\Entity\TakeOutLocations;
  22. use App\Repository\ServiceRepository;
  23. use App\Repository\StationRepository;
  24. use App\Service\CountryCurrencyResolver;
  25. use App\Service\DefaultCityProvider;
  26. use App\Service\Features;
  27. use App\Service\HomepageCityListingsBlockProvider;
  28. use App\Service\ListingRotationApi;
  29. use App\Service\ListingService;
  30. use App\Service\ProfileList;
  31. use App\Service\ProfileListingDataCreator;
  32. use App\Service\ProfileListSpecificationService;
  33. use App\Service\ProfileFilterService;
  34. use App\Service\ProfileTopBoard;
  35. use App\Service\Top100ProfilesService;
  36. use App\Specification\ElasticSearch\ISpecification;
  37. use App\Specification\Profile\ProfileHasApartments;
  38. use App\Specification\Profile\ProfileHasComments;
  39. use App\Specification\Profile\ProfileHasVideo;
  40. use App\Specification\Profile\ProfileIdIn;
  41. use App\Specification\Profile\ProfileIdINOrderedByINValues;
  42. use App\Specification\Profile\ProfileIdNotIn;
  43. use App\Specification\Profile\ProfileIsApproved;
  44. use App\Specification\Profile\ProfileIsElite;
  45. use App\Specification\Profile\ProfileIsLocated;
  46. use App\Specification\Profile\ProfileIsProvidingOneOfServices;
  47. use App\Specification\Profile\ProfileIsProvidingTakeOut;
  48. use App\Specification\Profile\ProfileWithAge;
  49. use App\Specification\Profile\ProfileWithBodyType;
  50. use App\Specification\Profile\ProfileWithBreastType;
  51. use App\Specification\Profile\ProfileWithHairColor;
  52. use App\Specification\Profile\ProfileWithNationality;
  53. use App\Specification\Profile\ProfileWithApartmentsOneHourPrice;
  54. use App\Specification\Profile\ProfileWithPrivateHaircut;
  55. use Flagception\Bundle\FlagceptionBundle\Annotations\Feature;
  56. use Happyr\DoctrineSpecification\Filter\Filter;
  57. use Happyr\DoctrineSpecification\Logic\OrX;
  58. use Porpaginas\Doctrine\ORM\ORMQueryResult;
  59. use Porpaginas\Page;
  60. use Psr\Cache\CacheItemPoolInterface;
  61. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  62. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
  63. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  64. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  65. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  66. use Symfony\Component\HttpFoundation\Request;
  67. use Happyr\DoctrineSpecification\Spec;
  68. use Symfony\Component\HttpFoundation\RequestStack;
  69. use Symfony\Component\HttpFoundation\Response;
  70. /**
  71.  * @see \App\Console\Export\ExportRotationListingsConfigCommand for listing API endpoints
  72.  */
  73. #[Cache(maxage60, public: true)]
  74. class ProfileListController extends AbstractController
  75. {
  76.     use ExtendedPaginationTrait;
  77.     use SpecTrait;
  78.     use ProfileMinPriceTrait;
  79.     use ResponseTrait;
  80.     const ENTRIES_ON_PAGE 36;
  81.     const RESULT_SOURCE_COUNTY 'county';
  82.     const RESULT_SOURCE_DISTRICT 'district';
  83.     const RESULT_SOURCE_STATION 'station';
  84.     const RESULT_SOURCE_APPROVED 'approved';
  85.     const RESULT_SOURCE_WITH_COMMENTS 'with_comments';
  86.     const RESULT_SOURCE_WITH_VIDEO 'with_video';
  87.     const RESULT_SOURCE_WITH_SELFIE 'with_selfie';
  88.     const RESULT_SOURCE_TOP_100 'top_100';
  89.     const RESULT_SOURCE_ELITE 'elite';
  90.     const RESULT_SOURCE_MASSEURS 'masseurs';
  91.     const RESULT_SOURCE_MASSAGE_SERVICE 'massage_service';
  92.     const RESULT_SOURCE_BY_PARAMS 'by_params';
  93.     const RESULT_SOURCE_SERVICE 'service';
  94.     const RESULT_SOURCE_CITY 'city';
  95.     const RESULT_SOURCE_COUNTRY 'country';
  96.     const CACHE_ITEM_STATION_ADDED_PROFILES 'station_added_profiles_ids_';
  97.     const RESULT_SOURCE_WITH_WHATSAPP 'with_whatsapp';
  98.     const RESULT_SOURCE_WITH_TELEGRAM 'with_telegram';
  99.     const RESULT_SOURCE_EIGHTEEN_YEARS_OLD 'eighteen_years_old';
  100.     const RESULT_SOURCE_BIG_ASS 'big_ass';
  101.     const RESULT_SOURCE_WITH_TATTOO 'with_tattoo';
  102.     const RESULT_SOURCE_WITH_PIERCING 'with_piercing';
  103.     const RESULT_SOURCE_ROUND_THE_CLOCK 'round_the_clock';
  104.     const RESULT_SOURCE_FOR_TWO_HOURS 'for_two_hours';
  105.     const RESULT_SOURCE_FOR_HOUR 'for_hour';
  106.     const RESULT_SOURCE_EXPRESS_PROGRAM 'express_program';
  107.     private ?string $source null;
  108.     public function __construct(
  109.         private RequestStack $requestStack,
  110.         private ProfileList                     $profileList,
  111.         private CountryCurrencyResolver         $countryCurrencyResolver,
  112.         private ServiceRepository               $serviceRepository,
  113.         private ListingService                  $listingService,
  114.         private Features                        $features,
  115.         private ProfileFilterService            $profilesFilterService,
  116.         private ProfileListSpecificationService $profileListSpecificationService,
  117.         private ProfileListingDataCreator       $profileListingDataCreator,
  118.         private Top100ProfilesService           $top100ProfilesService,
  119.         private CacheItemPoolInterface          $stationAddedProfilesCache,
  120.         private ParameterBagInterface           $parameterBag,
  121.         private ListingRotationApi              $listingRotationApi,
  122.         private ProfileTopBoard                 $profileTopBoard,
  123.         private HomepageCityListingsBlockProvider $homepageCityListingsBlockProvider,
  124.     ) {}
  125.     /**
  126.      * @Feature("has_masseurs")
  127.      */
  128.     #[ParamConverter("city"converter"city_converter")]
  129.     public function listForMasseur(City $cityServiceRepository $serviceRepository): Response
  130.     {
  131.         $specs $this->profileListSpecificationService->listForMasseur($city);
  132.         $response = new Response();
  133.         $massageGroupServices $serviceRepository->findBy(['group' => ServiceGroups::MASSAGE]);
  134.         $alternativeSpec $this->getORSpecForItemsArray([$massageGroupServices], function($item): ProfileIsProvidingOneOfServices {
  135.             return new ProfileIsProvidingOneOfServices($item);
  136.         });
  137.         $result $this->paginatedListing($city'/city/{city}/masseur', ['city' => $city->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_MASSAGE_SERVICE$response);
  138.         return $this->render('ProfileList/list.html.twig', [
  139.             'profiles' => $result,
  140.             'source' => $this->source,
  141.             'source_default' => self::RESULT_SOURCE_MASSEURS,
  142.             'recommendationSpec' => $specs->recommendationSpec(),
  143.         ], response$response);
  144.     }
  145.     /**
  146.      * @Feature("extra_category_big_ass")
  147.      */
  148.     #[ParamConverter("city"converter"city_converter")]
  149.     public function listBigAss(Request $requestCity $city): Response
  150.     {
  151.         $specs $this->profileListSpecificationService->listBigAss();
  152.         $response = new Response();
  153.         $result $this->paginatedListing($city'/city/{city}/category/big_ass', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  154.         return $this->render('ProfileList/list.html.twig', [
  155.             'profiles' => $result,
  156.             'source' => $this->source,
  157.             'source_default' => self::RESULT_SOURCE_BIG_ASS,
  158.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  159.                 'city' => $city->getUriIdentity(),
  160.                 'page' => $this->getCurrentPageNumber(),
  161.             ]),
  162.             'recommendationSpec' => $specs->recommendationSpec(),
  163.         ], response$response);
  164.     }
  165.     public function listByDefaultCity(ParameterBagInterface $parameterBagRequest $request): Response
  166.     {
  167.         $controller get_class($this).'::listByCity';
  168.         $path = [
  169.             'city' => $parameterBag->get('default_city'),
  170.             'subRequest' => true,
  171.         ];
  172.         //чтобы в обработчике можно было понять, по какому роуту зашли
  173.         $request->request->set('_route''profile_list.list_by_city');
  174.         return $this->forward($controller$path);
  175.     }
  176.     private function paginatedListing(City $city, ?string $apiEndpoint, array $apiParams, ?Filter $listingSpec null, ?OrX $alternativeSpec null, ?string $alternativeSource null, ?Response $response null): Page
  177.     {
  178.         $topPlacement $this->profileTopBoard->topPlacementSatisfiedBy($city$listingSpec);
  179.         $topPlacement?->setTopCard(); // mark as top card for UI
  180.         $page $this->getCurrentPageNumber();
  181.         $apiParams['city'] = $city->getId();
  182.         try {
  183.             if (null === $apiEndpoint) {
  184.                 throw new \RuntimeException('Empty API endpoint to switch to legacy listing query.');
  185.             }
  186.             $result $this->listingRotationApi->paginate($apiEndpoint$apiParams$page$topPlacement);
  187.             $response?->setMaxAge(10);
  188.         } catch (\Exception) {
  189.             $avoidOrTopPlacement = (null !== $topPlacement && $page 2) ? $topPlacement null;
  190.             $result $this->profileList->list($citynull$listingSpec, [], truenullProfileList::ORDER_BY_STATUS,
  191.                 nulltruenull, [Genders::FEMALE], $avoidOrTopPlacement);
  192.         }
  193.         if (null !== $alternativeSpec || null !== $alternativeSource) {
  194.             $prevCount $result->count();
  195.             $result $this->checkEmptyResultNotMasseur($result$city$alternativeSpec$alternativeSource);
  196.             if ($result->count() > $prevCount) {
  197.                 $response?->setMaxAge(60);
  198.             }
  199.         }
  200.         return $result;
  201.     }
  202.     #[ParamConverter("city"converter"city_converter")]
  203.     public function listByCity(ParameterBagInterface $parameterBagRequest $requestCity $citybool $subRequest false): Response
  204.     {
  205.         $page $this->getCurrentPageNumber();
  206.         if ($this->features->redirect_default_city_to_homepage() && false === $subRequest && $city->equals($parameterBag->get('default_city')) && $page 2) {
  207.             return $this->redirectToRoute('homepage', [], 301);
  208.         }
  209.         $specs $this->profileListSpecificationService->listByCity();
  210.         $response = new Response();
  211.         $result $this->paginatedListing($city'/city/{city}', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  212.         $homepageCityListingsBlock null;
  213.         if ($this->shouldShowHomepageCityListingsBlock($city$page$subRequest)) {
  214.             $homepageCityListingsBlock $this->homepageCityListingsBlockProvider->getForCity($city);
  215.         }
  216.         return $this->render('ProfileList/list.html.twig', [
  217.             'profiles' => $result,
  218.             'homepage_city_listings_block' => $homepageCityListingsBlock,
  219.             'recommendationSpec' => $specs->recommendationSpec(),
  220.         ], response$response);
  221.     }
  222.     /**
  223.      * @Feature("intim_moscow_listing")
  224.      */
  225.     #[Cache(maxage3600, public: true)]
  226.     public function listIntim(DefaultCityProvider $defaultCityProvider): Response
  227.     {
  228.         $city $defaultCityProvider->getDefaultCity();
  229.         $request $this->requestStack->getCurrentRequest();
  230.         $request?->attributes->set('city'$city);
  231.         $specs $this->profileListSpecificationService->listByCity();
  232.         $response = new Response();
  233.         $result $this->paginatedListing($city'/city/{city}/intim', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  234.         $result $this->shuffleProfilesOnPage($result);
  235.         $response->setMaxAge(3600);
  236.         return $this->render('ProfileList/list.html.twig', [
  237.             'profiles' => $result,
  238.             'city' => $city,
  239.             'recommendationSpec' => $specs->recommendationSpec(),
  240.         ], response$response);
  241.     }
  242.     #[ParamConverter("city"converter"city_converter")]
  243.     #[Entity("county"expr"repository.ofUriIdentityWithinCity(county, city)")]
  244.     public function listByCounty(Request $requestCity $cityCounty $county): Response
  245.     {
  246.         if (!$city->hasCounty($county)) {
  247.             throw $this->createNotFoundException();
  248.         }
  249.         $specs $this->profileListSpecificationService->listByCounty($county);
  250.         $response = new Response();
  251.         $alternativeSpec Spec::orX(ProfileIsLocated::withinCounties($city$city->getCounties()->toArray()));
  252.         $result $this->paginatedListing($city'/city/{city}/county/{county}', ['city' => $city->getId(), 'county' => $county->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_COUNTY$response);
  253.         return $this->render('ProfileList/list.html.twig', [
  254.             'profiles' => $result,
  255.             'source' => $this->source,
  256.             'source_default' => self::RESULT_SOURCE_COUNTY,
  257.             'county' => $county,
  258.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  259.                 'city' => $city->getUriIdentity(),
  260.                 'county' => $county->getUriIdentity(),
  261.                 'page' => $this->getCurrentPageNumber()
  262.             ]),
  263.             'recommendationSpec' => $specs->recommendationSpec(),
  264.         ], response$response);
  265.     }
  266.     #[ParamConverter("city"converter"city_converter")]
  267.     #[Entity("district"expr"repository.ofUriIdentityWithinCity(district, city)")]
  268.     public function listByDistrict(Request $requestCity $cityDistrict $district): Response
  269.     {
  270.         if (!$city->hasDistrict($district)) {
  271.             throw $this->createNotFoundException();
  272.         }
  273.         $specs $this->profileListSpecificationService->listByDistrict($district);
  274.         $response = new Response();
  275.         $alternativeSpec Spec::orX(ProfileIsLocated::withinDistricts($city$city->getDistricts()->toArray()));
  276.         $result $this->paginatedListing($city'/city/{city}/district/{district}', ['city' => $city->getId(), 'district' => $district->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_DISTRICT$response);
  277.         return $this->render('ProfileList/list.html.twig', [
  278.             'profiles' => $result,
  279.             'source' => $this->source,
  280.             'source_default' => self::RESULT_SOURCE_DISTRICT,
  281.             'district' => $district,
  282.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  283.                 'city' => $city->getUriIdentity(),
  284.                 'district' => $district->getUriIdentity(),
  285.                 'page' => $this->getCurrentPageNumber()
  286.             ]),
  287.             'recommendationSpec' => $specs->recommendationSpec(),
  288.         ], response$response);
  289.     }
  290.     /**
  291.      * @Feature("extra_category_without_prepayment")
  292.      */
  293.     #[ParamConverter("city"converter"city_converter")]
  294.     public function listWithoutPrepayment(Request $requestCity $city): Response
  295.     {
  296.         $listingData $this->profileListingDataCreator->getListingDataForFilter('listWithoutPrepayment', [], $city);
  297.         $specs $listingData['specs'];
  298.         $listingTypeName $listingData['listingTypeName'];
  299.         $response = new Response();
  300.         $result $this->paginatedListing($city'/city/{city}/category/without_prepayment', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  301.         $request->attributes->set('profiles_count'$result->count());
  302.         $request->attributes->set('listingTypeName'$listingTypeName);
  303.         $request->attributes->set('city'$city);
  304.         return $this->render('ProfileList/list.html.twig', [
  305.             'profiles' => $result,
  306.             'source' => $this->source,
  307.             'source_default' => 'without_prepayment',
  308.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  309.                 'city' => $city->getUriIdentity(),
  310.                 'page' => $this->getCurrentPageNumber(),
  311.             ]),
  312.             'recommendationSpec' => $specs->recommendationSpec(),
  313.         ], response$response);
  314.     }
  315.     #[ParamConverter("city"converter"city_converter")]
  316.     #[Entity("station"expr"repository.ofUriIdentityWithinCity(station, city)")]
  317.     public function listByStation(Request $requestCity $cityStation $station): Response
  318.     {
  319.         if (!$city->hasStation($station)) {
  320.             throw $this->createNotFoundException();
  321.         }
  322.         $specs $this->profileListSpecificationService->listByStation($station);
  323.         $response = new Response();
  324.         $result $this->paginatedListing($city'/city/{city}/station/{station}', ['city' => $city->getId(), 'station' => $station->getId()], $specs->spec(), nullnull$response);
  325.         $prevCount $result->count();
  326.         if (true === $this->features->station_page_add_profiles()) {
  327.             $spread $this->parameterBag->get('app.profile.station_page.added_profiles.spread');
  328.             $result $this->addSinglePageStationResults($result$city$station$spread ?: 5);
  329.         }
  330.         if (null !== $station->getDistrict()) {
  331.             $result $this->checkEmptyResultNotMasseur($result$citySpec::orX(ProfileIsLocated::nearStations($city$station->getDistrict()->getStations()->toArray())), self::RESULT_SOURCE_STATION);
  332.         } else {
  333.             $result $this->checkCityAndCountrySource($result$city);
  334.         }
  335.         if ($result->count() > $prevCount) {
  336.             $response?->setMaxAge(60);
  337.         }
  338.         return $this->render('ProfileList/list.html.twig', [
  339.             'profiles' => $result,
  340.             'source' => $this->source,
  341.             'source_default' => self::RESULT_SOURCE_STATION,
  342.             'station' => $station,
  343.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  344.                 'city' => $city->getUriIdentity(),
  345.                 'station' => $station->getUriIdentity(),
  346.                 'page' => $this->getCurrentPageNumber()
  347.             ]),
  348.             'recommendationSpec' => $specs->recommendationSpec(),
  349.         ], response$response);
  350.     }
  351.     private function addSinglePageStationResults(Page $resultCity $cityStation $stationint $spread): Page
  352.     {
  353.         if ($result->totalCount() >= $result->getCurrentLimit()) {
  354.             return $result;
  355.         }
  356.         $addedProfileIds $this->stationAddedProfilesCache->get(self::CACHE_ITEM_STATION_ADDED_PROFILES $station->getId(), function () use ($result$city$station$spread): array {
  357.             $currentSpread rand(0$spread);
  358.             $plannedTotalCount $result->getCurrentLimit() - $spread $currentSpread;
  359.             $result iterator_to_array($result->getIterator());
  360.             $originalProfileIds $this->extractProfileIds($result);
  361.             if ($station->getDistrict()) {
  362.                 $result $this->addSinglePageResultsUptoAmount($result$citySpec::orX(ProfileIsLocated::withinDistrict($station->getDistrict())), $plannedTotalCount);
  363.             }
  364.             if ($station->getDistrict()?->getCounty()) {
  365.                 $result $this->addSinglePageResultsUptoAmount($result$citySpec::orX(ProfileIsLocated::withinCounty($station->getDistrict()->getCounty())), $plannedTotalCount);
  366.             }
  367.             $result $this->addSinglePageResultsUptoAmount($result$citySpec::orX(ProfileIsLocated::withinCity($city)), $plannedTotalCount);
  368.             $result $this->extractProfileIds($result);
  369.             return array_diff($result$originalProfileIds);
  370.         });
  371.         $addedProfileIds array_slice($addedProfileIds0$result->getCurrentLimit() - $result->totalCount());
  372.         $originalProfiles iterator_to_array($result->getIterator());
  373.         $addedProfiles $this->listActiveWithinCityOrderedByStatusWithSpecAvoidingTopPlacementLimited($city, new ProfileIdIn($addedProfileIds), null, [Genders::FEMALE], count($addedProfileIds));
  374.         $newResult array_merge($originalProfiles$addedProfiles);
  375.         return new FakeORMQueryPage(01$result->getCurrentLimit(), count($newResult), $newResult);
  376.     }
  377.     private function addSinglePageResultsUptoAmount(array $resultCity $city, ?Filter $specsint $totalCount): array
  378.     {
  379.         $toAdd $totalCount count($result);
  380.         $currentResultIds $this->extractProfileIds($result);
  381.         $resultsToAdd $this->listActiveWithinCityOrderedByStatusWithSpecAvoidingTopPlacementLimited($city$specs, [new ProfileIdNotIn($currentResultIds)], [Genders::FEMALE], $toAdd);
  382.         $result array_merge($result$resultsToAdd);
  383.         return $result;
  384.     }
  385.     #[ParamConverter("city"converter"city_converter")]
  386.     public function listByStations(City $citystring $stationsStationRepository $stationRepository): Response
  387.     {
  388.         $stationIds explode(','$stations);
  389.         $stations $stationRepository->findBy(['uriIdentity' => $stationIds]);
  390.         $specs $this->profileListSpecificationService->listByStations($stations);
  391.         $response = new Response();
  392.         $result $this->paginatedListing($citynull, [], $specs->spec(), nullnull$response);
  393.         return $this->render('ProfileList/list.html.twig', [
  394.             'profiles' => $result,
  395.             'recommendationSpec' => $specs->recommendationSpec(),
  396.         ]);
  397.     }
  398.     #[ParamConverter("city"converter"city_converter")]
  399.     public function listApproved(Request $requestCity $city): Response
  400.     {
  401.         $specs $this->profileListSpecificationService->listApproved();
  402.         $response = new Response();
  403.         $result $this->paginatedListing($city'/city/{city}/approved', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  404.         $prevCount $result->count();
  405.         if ($this->features->fill_empty_profile_list() && $result->count() == 0) {
  406.             $this->source self::RESULT_SOURCE_WITH_COMMENTS;
  407.             $result $this->listRandomSinglePage($citynull, new ProfileHasComments(), nulltruefalse);
  408.             if ($result->count() == 0) {
  409.                 $this->source self::RESULT_SOURCE_WITH_VIDEO;
  410.                 $result $this->listRandomSinglePage($citynull, new ProfileHasVideo(), nulltruefalse);
  411.             }
  412.             if ($result->count() == 0) {
  413.                 $this->source self::RESULT_SOURCE_ELITE;
  414.                 $result $this->listRandomSinglePage($citynull$this->getSpecForEliteGirls($city), nulltruenull);
  415.             }
  416.             $result $this->checkEmptyResultNotMasseur($result$citynullself::RESULT_SOURCE_CITY);
  417.         }
  418.         if ($result->count() > $prevCount) {
  419.             $response?->setMaxAge(60);
  420.         }
  421.         return $this->render('ProfileList/list.html.twig', [
  422.             'profiles' => $result,
  423.             'source' => $this->source,
  424.             'source_default' => self::RESULT_SOURCE_APPROVED,
  425.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  426.                 'city' => $city->getUriIdentity(),
  427.                 'page' => $this->getCurrentPageNumber()
  428.             ]),
  429.             'recommendationSpec' => $specs->recommendationSpec(),
  430.         ], response$response);
  431.     }
  432.     /**
  433.      * @Feature("extra_category_with_whatsapp")
  434.      */
  435.     #[ParamConverter("city"converter"city_converter")]
  436.     public function listWithWhatsapp(Request $requestCity $city): Response
  437.     {
  438.         $specs $this->profileListSpecificationService->listWithWhatsapp();
  439.         $response = new Response();
  440.         $result $this->paginatedListing($city'/city/{city}/category/whatsapp', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  441.         return $this->render('ProfileList/list.html.twig', [
  442.             'profiles' => $result,
  443.             'source' => $this->source,
  444.             'source_default' => self::RESULT_SOURCE_WITH_WHATSAPP,
  445.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  446.                 'city' => $city->getUriIdentity(),
  447.                 'page' => $this->getCurrentPageNumber(),
  448.             ]),
  449.             'recommendationSpec' => $specs->recommendationSpec(),
  450.         ], response$response);
  451.     }
  452.     /**
  453.      * @Feature("extra_category_with_telegram")
  454.      */
  455.     #[ParamConverter("city"converter"city_converter")]
  456.     public function listWithTelegram(Request $requestCity $city): Response
  457.     {
  458.         $specs $this->profileListSpecificationService->listWithTelegram();
  459.         $response = new Response();
  460.         $result $this->paginatedListing($city'/city/{city}/category/telegram', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  461.         return $this->render('ProfileList/list.html.twig', [
  462.             'profiles' => $result,
  463.             'source' => $this->source,
  464.             'source_default' => self::RESULT_SOURCE_WITH_TELEGRAM,
  465.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  466.                 'city' => $city->getUriIdentity(),
  467.                 'page' => $this->getCurrentPageNumber(),
  468.             ]),
  469.             'recommendationSpec' => $specs->recommendationSpec(),
  470.         ], response$response);
  471.     }
  472.     /**
  473.      * @Feature("extra_category_eighteen_years_old")
  474.      */
  475.     #[ParamConverter("city"converter"city_converter")]
  476.     public function listEighteenYearsOld(Request $requestCity $city): Response
  477.     {
  478.         $specs $this->profileListSpecificationService->listEighteenYearsOld();
  479.         $response = new Response();
  480.         $result $this->paginatedListing($city'/city/{city}/category/eighteen_years_old', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  481.         return $this->render('ProfileList/list.html.twig', [
  482.             'profiles' => $result,
  483.             'source' => $this->source,
  484.             'source_default' => self::RESULT_SOURCE_EIGHTEEN_YEARS_OLD,
  485.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  486.                 'city' => $city->getUriIdentity(),
  487.                 'page' => $this->getCurrentPageNumber(),
  488.             ]),
  489.             'recommendationSpec' => $specs->recommendationSpec(),
  490.         ], response$response);
  491.     }
  492.     /**
  493.      * @Feature("extra_category_rublevskie")
  494.      */
  495.     #[ParamConverter("city"converter"city_converter")]
  496.     public function listRublevskie(Request $requestCity $city): Response
  497.     {
  498.         if ($city->getUriIdentity() !== 'moscow') {
  499.             throw $this->createNotFoundException();
  500.         }
  501.         $specs $this->profileListSpecificationService->listRublevskie($city);
  502.         $response = new Response();
  503.         $result $this->paginatedListing($city'/city/{city}/category/rublevskie', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  504.         return $this->render('ProfileList/list.html.twig', [
  505.             'profiles' => $result,
  506.             'source' => $this->source,
  507.             'source_default' => 'rublevskie',
  508.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  509.                 'city' => $city->getUriIdentity(),
  510.                 'page' => $this->getCurrentPageNumber(),
  511.             ]),
  512.             'recommendationSpec' => $specs->recommendationSpec(),
  513.         ], response$response);
  514.     }
  515.     /**
  516.      * @Feature("extra_category_with_tattoo")
  517.      */
  518.     #[ParamConverter("city"converter"city_converter")]
  519.     public function listWithTattoo(Request $requestCity $city): Response
  520.     {
  521.         $specs $this->profileListSpecificationService->listWithTattoo();
  522.         $response = new Response();
  523.         $result $this->paginatedListing($city'/city/{city}/category/with_tattoo', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  524.         return $this->render('ProfileList/list.html.twig', [
  525.             'profiles' => $result,
  526.             'source' => $this->source,
  527.             'source_default' => self::RESULT_SOURCE_WITH_TATTOO,
  528.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  529.                 'city' => $city->getUriIdentity(),
  530.                 'page' => $this->getCurrentPageNumber(),
  531.             ]),
  532.             'recommendationSpec' => $specs->recommendationSpec(),
  533.         ], response$response);
  534.     }
  535.     #[ParamConverter("city"converter"city_converter")]
  536.     public function listWithComments(Request $requestCity $city): Response
  537.     {
  538.         $specs $this->profileListSpecificationService->listWithComments();
  539.         $response = new Response();
  540.         $result $this->paginatedListing($city'/city/{city}/with_comments', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  541.         $prevCount $result->count();
  542.         if ($this->features->fill_empty_profile_list() && $result->count() == 0) {
  543.             $this->source self::RESULT_SOURCE_APPROVED;
  544.             $result $this->listRandomSinglePage($citynull, new ProfileIsApproved(), nulltruefalse);
  545.             if ($result->count() == 0) {
  546.                 $this->source self::RESULT_SOURCE_WITH_VIDEO;
  547.                 $result $this->listRandomSinglePage($citynull, new ProfileHasVideo(), nulltruefalse);
  548.             }
  549.             if ($result->count() == 0) {
  550.                 $this->source self::RESULT_SOURCE_ELITE;
  551.                 $result $this->listRandomSinglePage($citynull$this->getSpecForEliteGirls($city), nulltruenull);
  552.             }
  553.             $result $this->checkEmptyResultNotMasseur($result$citynullself::RESULT_SOURCE_CITY);
  554.         }
  555.         if ($result->count() > $prevCount) {
  556.             $response?->setMaxAge(60);
  557.         }
  558.         return $this->render('ProfileList/list.html.twig', [
  559.             'profiles' => $result,
  560.             'source' => $this->source,
  561.             'source_default' => self::RESULT_SOURCE_WITH_COMMENTS,
  562.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  563.                 'city' => $city->getUriIdentity(),
  564.                 'page' => $this->getCurrentPageNumber()
  565.             ]),
  566.             'recommendationSpec' => $specs->recommendationSpec(),
  567.         ], response$response);
  568.     }
  569.     /**
  570.      * @Feature("extra_category_with_piercing")
  571.      */
  572.     #[ParamConverter("city"converter"city_converter")]
  573.     public function listWithPiercing(Request $requestCity $city): Response
  574.     {
  575.         $specs $this->profileListSpecificationService->listWithPiercing();
  576.         $response = new Response();
  577.         $result $this->paginatedListing($city'/city/{city}/category/with_piercing', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  578.         return $this->render('ProfileList/list.html.twig', [
  579.             'profiles' => $result,
  580.             'source' => $this->source,
  581.             'source_default' => self::RESULT_SOURCE_WITH_PIERCING,
  582.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  583.                 'city' => $city->getUriIdentity(),
  584.                 'page' => $this->getCurrentPageNumber(),
  585.             ]),
  586.             'recommendationSpec' => $specs->recommendationSpec(),
  587.         ], response$response);
  588.     }
  589.     #[ParamConverter("city"converter"city_converter")]
  590.     public function listWithVideo(Request $requestCity $city): Response
  591.     {
  592.         $specs $this->profileListSpecificationService->listWithVideo();
  593.         $response = new Response();
  594.         $result $this->paginatedListing($city'/city/{city}/with_video', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  595.         $prevCount $result->count();
  596.         if ($this->features->fill_empty_profile_list() && $result->count() == 0) {
  597.             $this->source self::RESULT_SOURCE_APPROVED;
  598.             $result $this->listRandomSinglePage($citynull, new ProfileIsApproved(), nulltruefalse);
  599.             if ($result->count() == 0) {
  600.                 $this->source self::RESULT_SOURCE_WITH_COMMENTS;
  601.                 $result $this->listRandomSinglePage($citynull, new ProfileHasComments(), nulltruefalse);
  602.             }
  603.             if ($result->count() == 0) {
  604.                 $this->source self::RESULT_SOURCE_ELITE;
  605.                 $result $this->listRandomSinglePage($citynull$this->getSpecForEliteGirls($city), nulltruenull);
  606.             }
  607.             $result $this->checkEmptyResultNotMasseur($result$citynullself::RESULT_SOURCE_CITY);
  608.         }
  609.         if ($result->count() > $prevCount) {
  610.             $response?->setMaxAge(60);
  611.         }
  612.         return $this->render('ProfileList/list.html.twig', [
  613.             'profiles' => $result,
  614.             'source' => $this->source,
  615.             'source_default' => self::RESULT_SOURCE_WITH_VIDEO,
  616.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  617.                 'city' => $city->getUriIdentity(),
  618.                 'page' => $this->getCurrentPageNumber()
  619.             ]),
  620.             'recommendationSpec' => $specs->recommendationSpec(),
  621.         ], response$response);
  622.     }
  623.      /**
  624.      * @Feature("extra_category_round_the_clock")
  625.      */
  626.     #[ParamConverter("city"converter"city_converter")]
  627.     public function listRoundTheClock(Request $requestCity $city): Response
  628.     {
  629.         $specs $this->profileListSpecificationService->listRoundTheClock();
  630.         $response = new Response();
  631.         $result $this->paginatedListing($city'/city/{city}/category/round_the_clock', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  632.         return $this->render('ProfileList/list.html.twig', [
  633.             'profiles' => $result,
  634.             'source' => $this->source,
  635.             'source_default' => self::RESULT_SOURCE_ROUND_THE_CLOCK,
  636.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  637.                 'city' => $city->getUriIdentity(),
  638.                 'page' => $this->getCurrentPageNumber(),
  639.             ]),
  640.             'recommendationSpec' => $specs->recommendationSpec(),
  641.         ], response$response);
  642.     }
  643.     /**
  644.      * @Feature("extra_category_for_two_hours")
  645.      */
  646.     #[ParamConverter("city"converter"city_converter")]
  647.     public function listForTwoHours(Request $requestCity $city): Response
  648.     {
  649.         $specs $this->profileListSpecificationService->listForTwoHours();
  650.         $response = new Response();
  651.         $result $this->paginatedListing($city'/city/{city}/category/for_two_hours', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  652.         return $this->render('ProfileList/list.html.twig', [
  653.             'profiles' => $result,
  654.             'source' => $this->source,
  655.             'source_default' => self::RESULT_SOURCE_FOR_TWO_HOURS,
  656.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  657.                 'city' => $city->getUriIdentity(),
  658.                 'page' => $this->getCurrentPageNumber(),
  659.             ]),
  660.             'recommendationSpec' => $specs->recommendationSpec(),
  661.         ], response$response);
  662.     }
  663.     /**
  664.      * @Feature("extra_category_for_hour")
  665.      */
  666.     #[ParamConverter("city"converter"city_converter")]
  667.     public function listForHour(Request $requestCity $city): Response
  668.     {
  669.         $specs $this->profileListSpecificationService->listForHour();
  670.         $response = new Response();
  671.         $result $this->paginatedListing($city'/city/{city}/category/for_hour', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  672.         return $this->render('ProfileList/list.html.twig', [
  673.             'profiles' => $result,
  674.             'source' => $this->source,
  675.             'source_default' => self::RESULT_SOURCE_FOR_HOUR,
  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_express_program")
  685.      */
  686.     #[ParamConverter("city"converter"city_converter")]
  687.     public function listExpress(Request $requestCity $city): Response
  688.     {
  689.         $specs $this->profileListSpecificationService->listExpress();
  690.         $response = new Response();
  691.         $result $this->paginatedListing($city'/city/{city}/category/express', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  692.         return $this->render('ProfileList/list.html.twig', [
  693.             'profiles' => $result,
  694.             'source' => $this->source,
  695.             'source_default' => self::RESULT_SOURCE_EXPRESS_PROGRAM,
  696.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  697.                 'city' => $city->getUriIdentity(),
  698.                 'page' => $this->getCurrentPageNumber(),
  699.             ]),
  700.             'recommendationSpec' => $specs->recommendationSpec(),
  701.         ], response$response);
  702.     }
  703.     /**
  704.      * @Feature("extra_category_grandmothers")
  705.      */
  706.     #[ParamConverter("city"converter"city_converter")]
  707.     public function listGrandmothers(Request $requestCity $city): Response
  708.     {
  709.         $specs $this->profileListSpecificationService->listGrandmothers();
  710.         $response = new Response();
  711.         $result $this->paginatedListing($city'/city/{city}/category/grandmothers', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  712.         return $this->render('ProfileList/list.html.twig', [
  713.             'profiles' => $result,
  714.             'source' => $this->source,
  715.             'source_default' => 'grandmothers',
  716.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  717.                 'city' => $city->getUriIdentity(),
  718.                 'page' => $this->getCurrentPageNumber(),
  719.             ]),
  720.             'recommendationSpec' => $specs->recommendationSpec(),
  721.         ], response$response);
  722.     }
  723.         /**
  724.      * @Feature("extra_category_big_breast")
  725.      */
  726.     #[ParamConverter("city"converter"city_converter")]
  727.     public function listBigBreast(Request $requestCity $city): Response
  728.     {
  729.         $specs $this->profileListSpecificationService->listBigBreast();
  730.         $response = new Response();
  731.         $result $this->paginatedListing($city'/city/{city}/category/big_breast', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  732.         return $this->render('ProfileList/list.html.twig', [
  733.             'profiles' => $result,
  734.             'source' => $this->source,
  735.             'source_default' => 'big_breast',
  736.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  737.                 'city' => $city->getUriIdentity(),
  738.                 'page' => $this->getCurrentPageNumber(),
  739.             ]),
  740.             'recommendationSpec' => $specs->recommendationSpec(),
  741.         ], response$response);
  742.     }
  743.     /**
  744.      * @Feature("extra_category_very_skinny")
  745.      */
  746.     #[ParamConverter("city"converter"city_converter")]
  747.     public function listVerySkinny(Request $requestCity $city): Response
  748.     {
  749.         $specs $this->profileListSpecificationService->listVerySkinny();
  750.         $response = new Response();
  751.         $result $this->paginatedListing($city'/city/{city}/category/very_skinny', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  752.         return $this->render('ProfileList/list.html.twig', [
  753.             'profiles' => $result,
  754.             'source' => $this->source,
  755.             'source_default' => 'very_skinny',
  756.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  757.                 'city' => $city->getUriIdentity(),
  758.                 'page' => $this->getCurrentPageNumber(),
  759.             ]),
  760.             'recommendationSpec' => $specs->recommendationSpec(),
  761.         ], response$response);
  762.     }
  763.     /**
  764.      * @Feature("extra_category_small_ass")
  765.      */
  766.     #[ParamConverter("city"converter"city_converter")]
  767.     public function listSmallAss(Request $requestCity $city): Response
  768.     {
  769.         $specs $this->profileListSpecificationService->listSmallAss();
  770.         $response = new Response();
  771.         $result $this->paginatedListing($city'/city/{city}/category/small_ass', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  772.         return $this->render('ProfileList/list.html.twig', [
  773.             'profiles' => $result,
  774.             'source' => $this->source,
  775.             'source_default' => 'small_ass',
  776.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  777.                 'city' => $city->getUriIdentity(),
  778.                 'page' => $this->getCurrentPageNumber(),
  779.             ]),
  780.             'recommendationSpec' => $specs->recommendationSpec(),
  781.         ], response$response);
  782.     }
  783.     /**
  784.      * @Feature("extra_category_beautiful_prostitutes")
  785.      */
  786.     #[ParamConverter("city"converter"city_converter")]
  787.     public function listBeautifulProstitutes(Request $requestCity $city): Response
  788.     {
  789.         $specs $this->profileListSpecificationService->listBeautifulProstitutes();
  790.         $response = new Response();
  791.         $result $this->paginatedListing($city'/city/{city}/category/beautiful_prostitutes', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  792.         return $this->render('ProfileList/list.html.twig', [
  793.             'profiles' => $result,
  794.             'source' => $this->source,
  795.             'source_default' => 'beautiful_prostitutes',
  796.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  797.                 'city' => $city->getUriIdentity(),
  798.                 'page' => $this->getCurrentPageNumber(),
  799.             ]),
  800.             'recommendationSpec' => $specs->recommendationSpec(),
  801.         ], response$response);
  802.     }
  803.     /**
  804.      * @Feature("extra_category_without_intermediaries")
  805.      */
  806.     #[ParamConverter("city"converter"city_converter")]
  807.     public function listWithoutIntermediaries(Request $requestCity $city): Response
  808.     {
  809.         $specs $this->profileListSpecificationService->listWithoutIntermediaries();
  810.         $response = new Response();
  811.         $result $this->paginatedListing($city'/city/{city}/category/without_intermediaries', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  812.         return $this->render('ProfileList/list.html.twig', [
  813.             'profiles' => $result,
  814.             'source' => $this->source,
  815.             'source_default' => 'without_intermediaries',
  816.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  817.                 'city' => $city->getUriIdentity(),
  818.                 'page' => $this->getCurrentPageNumber(),
  819.             ]),
  820.             'recommendationSpec' => $specs->recommendationSpec(),
  821.         ], response$response);
  822.     }
  823.     /**
  824.      * @Feature("extra_category_intim_services")
  825.      */
  826.     #[ParamConverter("city"converter"city_converter")]
  827.     public function intimServices(Request $requestCity $city): Response
  828.     {
  829.         $servicesByGroup $this->serviceRepository->allIndexedByGroup();
  830.         return $this->render('ProfileList/intim_services.html.twig', [
  831.             'city' => $city,
  832.             'servicesByGroup' => $servicesByGroup,
  833.             'skipSetCurrentListingPage' => true,
  834.         ]);
  835.     }
  836.     /**
  837.      * @Feature("extra_category_outcall")
  838.      */
  839.     #[ParamConverter("city"converter"city_converter")]
  840.     public function listOutcall(Request $requestCity $city): Response
  841.     {
  842.         $specs $this->profileListSpecificationService->listByOutcall();
  843.         $response = new Response();
  844.         $result $this->paginatedListing($city'/city/{city}/category/outcall', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  845.         return $this->render('ProfileList/list.html.twig', [
  846.             'profiles' => $result,
  847.             'source' => $this->source,
  848.             'source_default' => 'outcall',
  849.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  850.                 'city' => $city->getUriIdentity(),
  851.                 'page' => $this->getCurrentPageNumber(),
  852.             ]),
  853.             'recommendationSpec' => $specs->recommendationSpec(),
  854.         ], response$response);
  855.     }
  856.     /**
  857.      * @Feature("extra_category_dwarfs")
  858.      */
  859.     #[ParamConverter("city"converter"city_converter")]
  860.     public function listDwarfs(Request $requestCity $city): Response
  861.     {
  862.         $specs $this->profileListSpecificationService->listDwarfs();
  863.         $response = new Response();
  864.         $result $this->paginatedListing($city'/city/{city}/category/dwarfs', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  865.         return $this->render('ProfileList/list.html.twig', [
  866.             'profiles' => $result,
  867.             'source' => $this->source,
  868.             'source_default' => 'dwarfs',
  869.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  870.                 'city' => $city->getUriIdentity(),
  871.                 'page' => $this->getCurrentPageNumber(),
  872.             ]),
  873.             'recommendationSpec' => $specs->recommendationSpec(),
  874.         ], response$response);
  875.     }
  876.     #[ParamConverter("city"converter"city_converter")]
  877.     public function listWithSelfie(Request $requestCity $city): Response
  878.     {
  879.         $specs $this->profileListSpecificationService->listWithSelfie();
  880.         $response = new Response();
  881.         $result $this->paginatedListing($city'/city/{city}/with_selfie', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  882.         $prevCount $result->count();
  883.         if ($this->features->fill_empty_profile_list() && $result->count() == 0) {
  884.             $this->source self::RESULT_SOURCE_WITH_VIDEO;
  885.             $result $this->listRandomSinglePage($citynull, new ProfileHasVideo(), nulltruefalse);
  886.             if ($result->count() == 0) {
  887.                 $this->source self::RESULT_SOURCE_APPROVED;
  888.                 $result $this->listRandomSinglePage($citynull, new ProfileIsApproved(), nulltruefalse);
  889.             }
  890.             if ($result->count() == 0) {
  891.                 $this->source self::RESULT_SOURCE_ELITE;
  892.                 $result $this->listRandomSinglePage($citynull$this->getSpecForEliteGirls($city), nulltruenull);
  893.             }
  894.             $result $this->checkEmptyResultNotMasseur($result$citynullself::RESULT_SOURCE_CITY);
  895.         }
  896.         if ($result->count() > $prevCount) {
  897.             $response?->setMaxAge(60);
  898.         }
  899.         return $this->render('ProfileList/list.html.twig', [
  900.             'profiles' => $result,
  901.             'source' => $this->source,
  902.             'source_default' => self::RESULT_SOURCE_WITH_SELFIE,
  903.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  904.                 'city' => $city->getUriIdentity(),
  905.                 'page' => $this->getCurrentPageNumber()
  906.             ]),
  907.             'recommendationSpec' => $specs->recommendationSpec(),
  908.         ], response$response);
  909.     }
  910.     #[ParamConverter("city"converter"city_converter")]
  911.     #[Feature("extra_category_top_100")]
  912.     public function listTop100(Request $requestCity $city): Response
  913.     {
  914.         $specs $this->profileListSpecificationService->listApproved();
  915.         $result $this->top100ProfilesService->getSortedProfilesByVisits($city);
  916.         return $this->render('ProfileList/list.html.twig', [
  917.             'profiles' => $result,
  918.             'source' => self::RESULT_SOURCE_TOP_100,
  919.             'source_default' => self::RESULT_SOURCE_TOP_100,
  920.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  921.                 'city' => $city->getUriIdentity(),
  922.                 'page' => $this->getCurrentPageNumber(),
  923.             ]),
  924.             'recommendationSpec' => $specs->recommendationSpec(),
  925.         ]);
  926.     }
  927.     #[ParamConverter("city"converter"city_converter")]
  928.     public function listByPrice(Request $requestCountryCurrencyResolver $countryCurrencyResolverCity $citystring $priceTypeint $minPrice nullint $maxPrice null): Response
  929.     {
  930.         $specs $this->profileListSpecificationService->listByPrice($city$priceType$minPrice$maxPrice);
  931.         $response = new Response();
  932.         $apiEndpoint in_array($priceType, ['low''high''elite']) ? '/city/{city}/price/'.$priceType null;
  933.         $result $this->paginatedListing($city$apiEndpoint, ['city' => $city->getId()], $specs->spec(), nullnull$response);
  934.         $prevCount $result->count();
  935.         if ($this->features->fill_empty_profile_list() && $result->count() == 0) {
  936.             $result $this->processListByPriceEmptyResult($result$city$priceType$minPrice$maxPrice);
  937.         }
  938.         if ($result->count() > $prevCount) {
  939.             $response?->setMaxAge(60);
  940.         }
  941.         return $this->render('ProfileList/list.html.twig', [
  942.             'profiles' => $result,
  943.             'source' => $this->source,
  944.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  945.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  946.                 'city' => $city->getUriIdentity(),
  947.                 'priceType' => $priceType,
  948.                 'minPrice' => $minPrice,
  949.                 'maxPrice' => $maxPrice,
  950.                 'page' => $this->getCurrentPageNumber()
  951.             ]),
  952.             'recommendationSpec' => $specs->recommendationSpec(),
  953.         ], response$response);
  954.     }
  955.     private function processListByPriceEmptyResult(Page $resultCity $citystring $priceTypeint $minPrice nullint $maxPrice null)
  956.     {
  957.         if (!$this->features->fill_empty_profile_list())
  958.             return $result;
  959.         $this->source self::RESULT_SOURCE_BY_PARAMS;
  960.         if ($this->countryCurrencyResolver->getCurrencyFor($city->getCountryCode()) == 'RUB') {
  961.             if ($minPrice && $maxPrice) {
  962.                 if ($minPrice == 2000 && $maxPrice == 3000) {
  963.                     $priceSpec = [
  964.                         ProfileWithApartmentsOneHourPrice::range(15002000),
  965.                         ProfileWithApartmentsOneHourPrice::range(30004000),
  966.                     ];
  967.                 } else if ($minPrice == 3000 && $maxPrice == 4000) {
  968.                     $priceSpec = [
  969.                         ProfileWithApartmentsOneHourPrice::range(20003000),
  970.                         ProfileWithApartmentsOneHourPrice::range(40005000),
  971.                     ];
  972.                 } else if ($minPrice == 4000 && $maxPrice == 5000) {
  973.                     $priceSpec = [
  974.                         ProfileWithApartmentsOneHourPrice::range(30004000),
  975.                         ProfileWithApartmentsOneHourPrice::range(50006000),
  976.                     ];
  977.                 } else if ($minPrice == 5000 && $maxPrice == 6000) {
  978.                     $priceSpec = [
  979.                         ProfileWithApartmentsOneHourPrice::range(4000999999)
  980.                     ];
  981.                 } else {
  982.                     $priceSpec = [
  983.                         ProfileWithApartmentsOneHourPrice::range($minPrice$maxPrice)
  984.                     ];
  985.                 }
  986.                 $result $this->listRandomSinglePage($citynullnull$priceSpectruefalse);
  987.             } elseif ($maxPrice) {
  988.                 if ($maxPrice == 500) {
  989.                     $priceSpec ProfileWithApartmentsOneHourPrice::cheaperThan(1500);
  990.                     $result $this->listRandomSinglePage($citynull$priceSpecnulltruefalse);
  991.                     if ($result->count() == 0) {
  992.                         $priceSpec ProfileWithApartmentsOneHourPrice::range(15002000);
  993.                         $result $this->listRandomSinglePage($citynull$priceSpecnulltruefalse);
  994.                     }
  995.                 } else if ($maxPrice == 1500) {
  996.                     $priceSpec ProfileWithApartmentsOneHourPrice::range(15002000);
  997.                     $result $this->listRandomSinglePage($citynull$priceSpecnulltruefalse);
  998.                     if ($result->count() == 0) {
  999.                         $priceSpec ProfileWithApartmentsOneHourPrice::range(20003000);
  1000.                         $result $this->listRandomSinglePage($citynull$priceSpecnulltruefalse);
  1001.                     }
  1002.                 }
  1003.             } else {
  1004.                 switch ($priceType) {
  1005.                     case 'not_expensive':
  1006.                         $priceSpec ProfileWithApartmentsOneHourPrice::cheaperThan(2000);
  1007.                         break;
  1008.                     case 'high':
  1009.                         $priceSpec ProfileWithApartmentsOneHourPrice::range(30006000);
  1010.                         break;
  1011.                     case 'low':
  1012.                         $priceSpec ProfileWithApartmentsOneHourPrice::cheaperThan(2000);
  1013.                         break;
  1014.                     case 'elite':
  1015.                         $priceSpec ProfileWithApartmentsOneHourPrice::moreExpensiveThan(6000);
  1016.                         break;
  1017.                     default:
  1018.                         throw new \LogicException('Unknown price type');
  1019.                         break;
  1020.                 }
  1021.                 $result $this->listRandomSinglePage($citynull$priceSpecnulltruefalse);
  1022.             }
  1023.         }
  1024.         $result $this->checkEmptyResultNotMasseur($result$citynullself::RESULT_SOURCE_CITY);
  1025.         return $result;
  1026.     }
  1027.     #[ParamConverter("city"converter"city_converter")]
  1028.     public function listByAge(Request $requestCity $citystring $ageTypeint $minAge nullint $maxAge null): Response
  1029.     {
  1030.         $specs $this->profileListSpecificationService->listByAge($ageType$minAge$maxAge);
  1031.         $response = new Response();
  1032.         $apiEndpoint in_array($ageType, ['young''old']) ? '/city/{city}/age/'.$ageType null;
  1033.         $result $this->paginatedListing($city$apiEndpoint, ['city' => $city->getId()], $specs->spec(), nullnull$response);
  1034.         $prevCount $result->count();
  1035.         if ($this->features->fill_empty_profile_list() && $result->count() == 0) {
  1036.             $filled $this->processListByAgeEmptyResult($result$city$ageType$minAge$maxAge);
  1037.             if ($filled)
  1038.                 $result $filled;
  1039.         }
  1040.         if ($result->count() > $prevCount) {
  1041.             $response?->setMaxAge(60);
  1042.         }
  1043.         return $this->render('ProfileList/list.html.twig', [
  1044.             'profiles' => $result,
  1045.             'source' => $this->source,
  1046.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1047.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1048.                 'city' => $city->getUriIdentity(),
  1049.                 'ageType' => $ageType,
  1050.                 'minAge' => $minAge,
  1051.                 'maxAge' => $maxAge,
  1052.                 'page' => $this->getCurrentPageNumber()
  1053.             ]),
  1054.             'recommendationSpec' => $specs->recommendationSpec(),
  1055.         ], response$response);
  1056.     }
  1057.     private function processListByAgeEmptyResult(Page $resultCity $citystring $ageTypeint $minAge nullint $maxAge null)
  1058.     {
  1059.         if (!$this->features->fill_empty_profile_list())
  1060.             return $result;
  1061.         $this->source self::RESULT_SOURCE_BY_PARAMS;
  1062.         if ($minAge && !$maxAge) {
  1063.             $startMinAge $minAge;
  1064.             do {
  1065.                 $startMinAge -= 2;
  1066.                 $ageSpec ProfileWithAge::olderThan($startMinAge);
  1067.                 $result $this->listRandomSinglePage($citynull$ageSpecnulltruefalse);
  1068.             } while ($result->count() == && $startMinAge >= 18);
  1069.         } else if ($ageType == 'young') {
  1070.             $startMaxAge 20;
  1071.             do {
  1072.                 $startMaxAge += 2;
  1073.                 $ageSpec ProfileWithAge::youngerThan($startMaxAge);
  1074.                 $result $this->listRandomSinglePage($citynull$ageSpecnulltruefalse);
  1075.             } while ($result->count() == && $startMaxAge <= 100);
  1076.         }
  1077.         $result $this->checkEmptyResultNotMasseur($result$citynullself::RESULT_SOURCE_CITY);
  1078.         return $result;
  1079.     }
  1080.     #[ParamConverter("city"converter"city_converter")]
  1081.     public function listByHeight(Request $requestCity $citystring $heightType): Response
  1082.     {
  1083.         $specs $this->profileListSpecificationService->listByHeight($heightType);
  1084.         $response = new Response();
  1085.         $result $this->paginatedListing($city'/city/{city}/height/'.$heightType, ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1086.         return $this->render('ProfileList/list.html.twig', [
  1087.             'profiles' => $result,
  1088.             'source' => $this->source,
  1089.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1090.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1091.                 'city' => $city->getUriIdentity(),
  1092.                 'heightType' => $heightType,
  1093.                 'page' => $this->getCurrentPageNumber()
  1094.             ]),
  1095.             'recommendationSpec' => $specs->recommendationSpec(),
  1096.         ], response$response);
  1097.     }
  1098.     #[ParamConverter("city"converter"city_converter")]
  1099.     public function listByBreastType(Request $requestCity $citystring $breastType): Response
  1100.     {
  1101.         if (null === $type BreastTypes::getValueByUriIdentity($breastType)) {
  1102.             throw $this->createNotFoundException();
  1103.         }
  1104.         $specs $this->profileListSpecificationService->listByBreastType($breastType);
  1105.         $response = new Response();
  1106.         $alternativeSpec $this->getORSpecForItemsArray(BreastTypes::getList(), function($item): ProfileWithBreastType {
  1107.             return new ProfileWithBreastType($item);
  1108.         });
  1109.         $result $this->paginatedListing($city'/city/{city}/breasttype/'.$type, ['city' => $city->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_BY_PARAMS$response);
  1110.         return $this->render('ProfileList/list.html.twig', [
  1111.             'profiles' => $result,
  1112.             'source' => $this->source,
  1113.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1114.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1115.                 'city' => $city->getUriIdentity(),
  1116.                 'breastType' => $breastType,
  1117.                 'page' => $this->getCurrentPageNumber()
  1118.             ]),
  1119.             'recommendationSpec' => $specs->recommendationSpec(),
  1120.         ], response$response);
  1121.     }
  1122.     #[ParamConverter("city"converter"city_converter")]
  1123.     public function listByHairColor(Request $requestCity $citystring $hairColor): Response
  1124.     {
  1125.         if (null === $color HairColors::getValueByUriIdentity($hairColor)) {
  1126.             throw $this->createNotFoundException();
  1127.         }
  1128.         $specs $this->profileListSpecificationService->listByHairColor($hairColor);
  1129.         $response = new Response();
  1130.         $alternativeSpec $this->getORSpecForItemsArray(HairColors::getList(), function($item): ProfileWithHairColor {
  1131.             return new ProfileWithHairColor($item);
  1132.         });
  1133.         $result $this->paginatedListing($city'/city/{city}/haircolor/'.$color, ['city' => $city->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_BY_PARAMS$response);
  1134.         return $this->render('ProfileList/list.html.twig', [
  1135.             'profiles' => $result,
  1136.             'source' => $this->source,
  1137.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1138.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1139.                 'city' => $city->getUriIdentity(),
  1140.                 'hairColor' => $hairColor,
  1141.                 'page' => $this->getCurrentPageNumber()
  1142.             ]),
  1143.             'recommendationSpec' => $specs->recommendationSpec(),
  1144.         ], response$response);
  1145.     }
  1146.     #[ParamConverter("city"converter"city_converter")]
  1147.     public function listByBodyType(Request $requestCity $citystring $bodyType): Response
  1148.     {
  1149.         if (null === $type BodyTypes::getValueByUriIdentity($bodyType)) {
  1150.             throw $this->createNotFoundException();
  1151.         }
  1152.         $specs $this->profileListSpecificationService->listByBodyType($bodyType);
  1153.         $response = new Response();
  1154.         $alternativeSpec $this->getORSpecForItemsArray(BodyTypes::getList(), function($item): ProfileWithBodyType {
  1155.             return new ProfileWithBodyType($item);
  1156.         });
  1157.         $result $this->paginatedListing($city'/city/{city}/bodytype/'.$type, ['city' => $city->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_BY_PARAMS$response);
  1158.         return $this->render('ProfileList/list.html.twig', [
  1159.             'profiles' => $result,
  1160.             'source' => $this->source,
  1161.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1162.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1163.                 'city' => $city->getUriIdentity(),
  1164.                 'bodyType' => $bodyType,
  1165.                 'page' => $this->getCurrentPageNumber()
  1166.             ]),
  1167.             'recommendationSpec' => $specs->recommendationSpec(),
  1168.         ], response$response);
  1169.     }
  1170.     #[ParamConverter("city"converter"city_converter")]
  1171.     public function listByPlace(Request $requestCity $citystring $placeTypestring $takeOutLocation null): Response
  1172.     {
  1173.         $specs $this->profileListSpecificationService->listByPlace($placeType$takeOutLocation);
  1174.         if (null === $specs) {
  1175.             throw $this->createNotFoundException();
  1176.         }
  1177.         $response = new Response();
  1178.         $alternativeSpec $this->getORSpecForItemsArray(TakeOutLocations::getList(), function($item): ProfileIsProvidingTakeOut {
  1179.             return new ProfileIsProvidingTakeOut($item);
  1180.         });
  1181.         if ($placeType === 'take-out') {
  1182.             $alternativeSpec->orX(new ProfileHasApartments());
  1183.         }
  1184.         $apiEndpoint '/city/{city}/place/'.$placeType;
  1185.         if (null !== $takeOutLocation) {
  1186.             $apiEndpoint .= '/'.$takeOutLocation;
  1187.         }
  1188.         $result $this->paginatedListing($city$apiEndpoint, ['city' => $city->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_BY_PARAMS$response);
  1189.         return $this->render('ProfileList/list.html.twig', [
  1190.             'profiles' => $result,
  1191.             'source' => $this->source,
  1192.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1193.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1194.                 'city' => $city->getUriIdentity(),
  1195.                 'placeType' => $placeType,
  1196.                 'takeOutLocation' => TakeOutLocations::getUriIdentity(TakeOutLocations::getValueByUriIdentity($takeOutLocation)),
  1197.                 'page' => $this->getCurrentPageNumber()
  1198.             ]),
  1199.             'recommendationSpec' => $specs->recommendationSpec(),
  1200.         ], response$response);
  1201.     }
  1202.     #[ParamConverter("city"converter"city_converter")]
  1203.     public function listByPrivateHaircut(Request $requestCity $citystring $privateHaircut): Response
  1204.     {
  1205.         if(null === $type PrivateHaircuts::getValueByUriIdentity($privateHaircut))
  1206.             throw $this->createNotFoundException();
  1207.         $specs $this->profileListSpecificationService->listByPrivateHaircut($privateHaircut);
  1208.         $response = new Response();
  1209.         $apiEndpoint '/city/{city}/privatehaircut/'.$type;
  1210.         $alternativeSpec $this->getORSpecForItemsArray(PrivateHaircuts::getList(), function($item): ProfileWithPrivateHaircut {
  1211.             return new ProfileWithPrivateHaircut($item);
  1212.         });
  1213.         $result $this->paginatedListing($city$apiEndpoint, ['city' => $city->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_BY_PARAMS$response);
  1214.         return $this->render('ProfileList/list.html.twig', [
  1215.             'profiles' => $result,
  1216.             'source' => $this->source,
  1217.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1218.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1219.                 'city' => $city->getUriIdentity(),
  1220.                 'privateHaircut' => $privateHaircut,
  1221.                 'page' => $this->getCurrentPageNumber()
  1222.             ]),
  1223.             'recommendationSpec' => $specs->recommendationSpec(),
  1224.         ], response$response);
  1225.     }
  1226.     #[ParamConverter("city"converter"city_converter")]
  1227.     public function listByNationality(Request $requestCity $citystring $nationality): Response
  1228.     {
  1229.         if (null === $type Nationalities::getValueByUriIdentity($nationality))
  1230.             throw $this->createNotFoundException();
  1231.         $specs $this->profileListSpecificationService->listByNationality($nationality);
  1232.         $response = new Response();
  1233.         $alternativeSpec $this->getORSpecForItemsArray(Nationalities::getList(), function($item): ProfileWithNationality {
  1234.             return new ProfileWithNationality($item);
  1235.         });
  1236.         $apiEndpoint '/city/{city}/nationality/'.$type;
  1237.         $result $this->paginatedListing($city$apiEndpoint, ['city' => $city->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_BY_PARAMS$response);
  1238.         return $this->render('ProfileList/list.html.twig', [
  1239.             'profiles' => $result,
  1240.             'source' => $this->source,
  1241.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1242.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1243.                 'city' => $city->getUriIdentity(),
  1244.                 'nationality' => $nationality,
  1245.                 'page' => $this->getCurrentPageNumber()
  1246.             ]),
  1247.             'recommendationSpec' => $specs->recommendationSpec(),
  1248.         ], response$response);
  1249.     }
  1250.     #[ParamConverter("city"converter"city_converter")]
  1251.     #[ParamConverter("service"options: ['mapping' => ['service' => 'uriIdentity']])]
  1252.     public function listByProvidedService(Request $requestCity $cityService $service): Response
  1253.     {
  1254.         $specs $this->profileListSpecificationService->listByProvidedService($service$city);
  1255.         $response = new Response();
  1256.         $sameGroupServices $this->serviceRepository->findBy(['group' => $service->getGroup()]);
  1257.         $alternativeSpec $this->getORSpecForItemsArray([$sameGroupServices], function($item): ProfileIsProvidingOneOfServices {
  1258.             return new ProfileIsProvidingOneOfServices($item);
  1259.         });
  1260.         $result $this->paginatedListing($city'/city/{city}/service/{service}', ['city' => $city->getId(), 'service' => $service->getId()], $specs->spec(), $alternativeSpecself::RESULT_SOURCE_SERVICE$response);
  1261.         return $this->render('ProfileList/list.html.twig', [
  1262.             'profiles' => $result,
  1263.             'source' => $this->source,
  1264.             'source_default' => self::RESULT_SOURCE_SERVICE,
  1265.             'service' => $service,
  1266.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1267.                 'city' => $city->getUriIdentity(),
  1268.                 'service' => $service->getUriIdentity(),
  1269.                 'page' => $this->getCurrentPageNumber()
  1270.             ]),
  1271.             'recommendationSpec' => $specs->recommendationSpec(),
  1272.         ], response$response);
  1273.     }
  1274.     /**
  1275.      * @Feature("has_archive_page")
  1276.      */
  1277.     #[ParamConverter("city"converter"city_converter")]
  1278.     public function listArchived(Request $requestCity $city): Response
  1279.     {
  1280.         $result $this->profileList->list($citynullnullnullfalsenullProfileList::ORDER_BY_UPDATED);
  1281.         return $this->render('ProfileList/list.html.twig', [
  1282.             'profiles' => $result,
  1283.             'recommendationSpec' => new \App\Specification\ElasticSearch\ProfileIsNotArchived(), //ProfileIsArchived, согласно https://redminez.net/issues/28305 в реках выводятся неарзивные
  1284.         ]);
  1285.     }
  1286.     #[ParamConverter("city"converter"city_converter")]
  1287.     public function listNew(City $cityint $weeks 2): Response
  1288.     {
  1289.         $specs $this->profileListSpecificationService->listNew($weeks);
  1290.         $response = new Response();
  1291.         $result $this->paginatedListing($city'/city/{city}/recent', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  1292.         return $this->render('ProfileList/list.html.twig', [
  1293.             'profiles' => $result,
  1294.             'recommendationSpec' => $specs->recommendationSpec(),
  1295.         ], response$response);
  1296.     }
  1297.     #[ParamConverter("city"converter"city_converter")]
  1298.     public function listByNoRetouch(City $city): Response
  1299.     {
  1300.         $specs $this->profileListSpecificationService->listByNoRetouch();
  1301.         $response = new Response();
  1302.         $result $this->paginatedListing($city'/city/{city}/noretouch', ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1303.         return $this->render('ProfileList/list.html.twig', [
  1304.             'profiles' => $result,
  1305.             'profiles_count' => $result->count(),
  1306.             'source' => $this->source,
  1307.             'recommendationSpec' => $specs->recommendationSpec(),
  1308.         ], response$response);
  1309.     }
  1310.     #[ParamConverter("city"converter"city_converter")]
  1311.     public function listByNice(City $city): Response
  1312.     {
  1313.         $specs $this->profileListSpecificationService->listByNice();
  1314.         $response = new Response();
  1315.         $result $this->paginatedListing($city'/city/{city}/nice', ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1316.         return $this->render('ProfileList/list.html.twig', [
  1317.             'profiles' => $result,
  1318.             'source' => $this->source,
  1319.             'recommendationSpec' => $specs->recommendationSpec(),
  1320.         ], response$response);
  1321.     }
  1322.     #[ParamConverter("city"converter"city_converter")]
  1323.     public function listByOnCall(City $city): Response
  1324.     {
  1325.         $specs $this->profileListSpecificationService->listByOnCall();
  1326.         $response = new Response();
  1327.         $result $this->paginatedListing($city'/city/{city}/oncall', ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1328.         return $this->render('ProfileList/list.html.twig', [
  1329.             'profiles' => $result,
  1330.             'source' => $this->source,
  1331.             'recommendationSpec' => $specs->recommendationSpec(),
  1332.         ], response$response);
  1333.     }
  1334.     #[ParamConverter("city"converter"city_converter")]
  1335.     public function listForNight(City $city): Response
  1336.     {
  1337.         $specs $this->profileListSpecificationService->listForNight();
  1338.         $response = new Response();
  1339.         $result $this->paginatedListing($city'/city/{city}/fornight', ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1340.         return $this->render('ProfileList/list.html.twig', [
  1341.             'profiles' => $result,
  1342.             'source' => $this->source,
  1343.             'recommendationSpec' => $specs->recommendationSpec(),
  1344.         ], response$response);
  1345.     }
  1346.     private function getSpecForEliteGirls(City $city): Filter
  1347.     {
  1348.         $minPrice $this->countryCurrencyResolver->getValueByCountryCode($city->getCountryCode(), [
  1349.             'RUB' => 5000,
  1350.             'UAH' => 1500,
  1351.             'USD' => 100,
  1352.             'EUR' => 130,
  1353.         ]);
  1354.         return new ProfileIsElite($minPrice);
  1355.     }
  1356.     private function getElasticSearchSpecForEliteGirls(City $city): ISpecification
  1357.     {
  1358.         $minPrice $this->countryCurrencyResolver->getValueByCountryCode($city->getCountryCode(), [
  1359.             'RUB' => 5000,
  1360.             'UAH' => 1500,
  1361.             'USD' => 100,
  1362.             'EUR' => 130,
  1363.         ]);
  1364.         return new \App\Specification\ElasticSearch\ProfileIsElite($minPrice);
  1365.     }
  1366.     #[ParamConverter("city"converter"city_converter")]
  1367.     public function listForEliteGirls(CountryCurrencyResolver $countryCurrencyResolverRequest $requestCity $city): Response
  1368.     {
  1369.         $specs $this->profileListSpecificationService->listForEliteGirls($city);
  1370.         $response = new Response();
  1371.         $result $this->paginatedListing($city'/city/{city}/elite', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  1372.         $prevCount $result->count();
  1373.         if ($this->features->fill_empty_profile_list() && $result->count() == 0) {
  1374.             $prices = [
  1375.                 'RUB' => 5000,
  1376.                 'UAH' => 1500,
  1377.                 'USD' => 100,
  1378.                 'EUR' => 130,
  1379.             ];
  1380.             $currency $countryCurrencyResolver->getCurrencyFor($city->getCountryCode());
  1381.             if (isset($prices[$currency])) {
  1382.                 $minPrice $prices[$currency];
  1383.                 switch ($currency) {
  1384.                     case 'RUB':
  1385.                         $diff 1000;
  1386.                         break;
  1387.                     case 'UAH':
  1388.                         $diff 500;
  1389.                         break;
  1390.                     case 'USD':
  1391.                     case 'EUR':
  1392.                         $diff 20;
  1393.                         break;
  1394.                     default:
  1395.                         throw new \LogicException('Unexpected currency code');
  1396.                 }
  1397.                 while ($minPrice >= $diff) {
  1398.                     $minPrice -= $diff;
  1399.                     $result $this->listRandomSinglePage($citynullProfileWithApartmentsOneHourPrice::moreExpensiveThan($minPrice), nulltruefalse);
  1400.                     if ($result->count() > 0) {
  1401.                         $this->source self::RESULT_SOURCE_BY_PARAMS;
  1402.                         break;
  1403.                     }
  1404.                 }
  1405.                 $result $this->checkEmptyResultNotMasseur($result$citynullself::RESULT_SOURCE_CITY);
  1406.             }
  1407.         }
  1408.         if ($result->count() > $prevCount) {
  1409.             $response?->setMaxAge(60);
  1410.         }
  1411.         return $this->render('ProfileList/list.html.twig', [
  1412.             'profiles' => $result,
  1413.             'source' => $this->source,
  1414.             'source_default' => self::RESULT_SOURCE_BY_PARAMS,
  1415.             'category_url' => $this->generateUrl($request->attributes->get('_route'), [
  1416.                 'city' => $city->getUriIdentity(),
  1417.                 'page' => $this->getCurrentPageNumber()
  1418.             ]),
  1419.             'recommendationSpec' => $specs->recommendationSpec(),
  1420.         ], response$response);
  1421.     }
  1422.     #[ParamConverter("city"converter"city_converter")]
  1423.     public function listForRealElite(CountryCurrencyResolver $countryCurrencyResolverCity $city): Response
  1424.     {
  1425.         $specs $this->profileListSpecificationService->listForRealElite($city);
  1426.         $response = new Response();
  1427.         $result $this->paginatedListing($city'/city/{city}/realelite', ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1428.         return $this->render('ProfileList/list.html.twig', [
  1429.             'profiles' => $result,
  1430.             'source' => $this->source,
  1431.             'recommendationSpec' => $specs->recommendationSpec(),
  1432.         ], response$response);
  1433.     }
  1434.     #[ParamConverter("city"converter"city_converter")]
  1435.     public function listForVipPros(CountryCurrencyResolver $countryCurrencyResolverCity $city): Response
  1436.     {
  1437.         $specs $this->profileListSpecificationService->listForVipPros($city);
  1438.         $response = new Response();
  1439.         $result $this->paginatedListing($city'/city/{city}/vip', ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1440.         return $this->render('ProfileList/list.html.twig', [
  1441.             'profiles' => $result,
  1442.             'source' => $this->source,
  1443.             'recommendationSpec' => $specs->recommendationSpec(),
  1444.         ], response$response);
  1445.     }
  1446.     #[ParamConverter("city"converter"city_converter")]
  1447.     public function listForVipIndividual(CountryCurrencyResolver $countryCurrencyResolverCity $city): Response
  1448.     {
  1449.         $specs $this->profileListSpecificationService->listForVipIndividual($city);
  1450.         $response = new Response();
  1451.         $result $this->paginatedListing($city'/city/{city}/vipindi', ['city' => $city->getId()], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1452.         return $this->render('ProfileList/list.html.twig', [
  1453.             'profiles' => $result,
  1454.             'source' => $this->source,
  1455.             'recommendationSpec' => $specs->recommendationSpec(),
  1456.         ], response$response);
  1457.     }
  1458.     #[ParamConverter("city"converter"city_converter")]
  1459.     public function listForVipGirlsCity(City $city): Response
  1460.     {
  1461.         $specs $this->profileListSpecificationService->listForVipGirlsCity($city);
  1462.         $response = new Response();
  1463.         $result $this->paginatedListing($citynull, [], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1464.         return $this->render('ProfileList/list.html.twig', [
  1465.             'profiles' => $result,
  1466.             'source' => $this->source,
  1467.             'recommendationSpec' => $specs->recommendationSpec(),
  1468.         ], response$response);
  1469.     }
  1470.     #[ParamConverter("city"converter"city_converter")]
  1471.     public function listOfGirlfriends(City $city): Response
  1472.     {
  1473.         $specs $this->profileListSpecificationService->listOfGirlfriends();
  1474.         $response = new Response();
  1475.         $result $this->paginatedListing($citynull, [], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1476.         return $this->render('ProfileList/list.html.twig', [
  1477.             'profiles' => $result,
  1478.             'source' => $this->source,
  1479.             'recommendationSpec' => $specs->recommendationSpec(),
  1480.         ]);
  1481.     }
  1482.     #[ParamConverter("city"converter"city_converter")]
  1483.     public function listOfMostExpensive(City $city): Response
  1484.     {
  1485.         $specs $this->profileListSpecificationService->listOfMostExpensive($city);
  1486.         $response = new Response();
  1487.         $result $this->paginatedListing($citynull, [], $specs->spec(), nullself::RESULT_SOURCE_CITY$response);
  1488.         return $this->render('ProfileList/list.html.twig', [
  1489.             'profiles' => $result,
  1490.             'source' => $this->source,
  1491.             'recommendationSpec' => $specs->recommendationSpec(),
  1492.         ]);
  1493.     }
  1494.     #[ParamConverter("city"converter"city_converter")]
  1495.     public function listBdsm(City $cityServiceRepository $serviceRepositoryParameterBagInterface $parameterBag): Response
  1496.     {
  1497.         $specs $this->profileListSpecificationService->listBdsm();
  1498.         $response = new Response();
  1499.         $result $this->paginatedListing($city'/city/{city}/bdsm', ['city' => $city->getId()], $specs->spec(), nullnull$response);
  1500.         return $this->render('ProfileList/list.html.twig', [
  1501.             'profiles' => $result,
  1502.             'recommendationSpec' => $specs->recommendationSpec(),
  1503.         ], response$response);
  1504.     }
  1505.     #[ParamConverter("city"converter"city_converter")]
  1506.     public function listByGender(City $citystring $genderDefaultCityProvider $defaultCityProvider): Response
  1507.     {
  1508.         if ($city->getId() != $defaultCityProvider->getDefaultCity()->getId()) {
  1509.             throw $this->createNotFoundException();
  1510.         }
  1511.         if (null === Genders::getValueByUriIdentity($gender))
  1512.             throw $this->createNotFoundException();
  1513.         $specs $this->profileListSpecificationService->listByGender($gender);
  1514.         $response = new Response();
  1515.         $result $this->paginatedListing($citynull, [], $specs->spec(), nullnull$response);
  1516.         return $this->render('ProfileList/list.html.twig', [
  1517.             'profiles' => $result,
  1518.             'recommendationSpec' => $specs->recommendationSpec(),
  1519.         ]);
  1520.     }
  1521.     protected function checkCityAndCountrySource(Page $resultCity $city): Page
  1522.     {
  1523.         if (($result && $result->count() != 0) || false == $this->features->fill_empty_profile_list())
  1524.             return $result;
  1525.         $this->source self::RESULT_SOURCE_CITY;
  1526.         $result $this->listRandomSinglePage($citynullnullnulltruefalse);
  1527.         if ($result->count() == 0) {
  1528.             $this->source self::RESULT_SOURCE_COUNTRY;
  1529.             $result $this->listRandomSinglePage($city$city->getCountryCode(), nullnulltruefalse);
  1530.         }
  1531.         return $result;
  1532.     }
  1533.     protected function checkEmptyResultNotMasseur(Page $resultCity $city, ?OrX $alternativeSpecstring $source): Page
  1534.     {
  1535.         if ($result->count() != || false == $this->features->fill_empty_profile_list())
  1536.             return $result;
  1537.         if (null != $alternativeSpec) {
  1538.             $this->source $source;
  1539.             $result $this->listRandomSinglePage($citynull$alternativeSpecnulltruefalse);
  1540.         }
  1541.         if ($result->count() == 0)
  1542.             $result $this->checkCityAndCountrySource($result$city);
  1543.         return $result;
  1544.     }
  1545.     /**
  1546.      * Сейчас не используется, решили доставать их всех соседних подкатегорий разом.
  1547.      * Пока оставил, вдруг передумают.
  1548.      * @deprecated
  1549.      */
  1550.     public function listByNextSimilarCategories(callable $listMethod$requestCategory, array $similarItems): ORMQueryResult
  1551.     {
  1552.         $similarItems array_filter($similarItems, function ($item) use ($requestCategory): bool {
  1553.             return $item != $requestCategory;
  1554.         });
  1555.         //shuffle($similarItems);
  1556.         $item null;
  1557.         $result null;
  1558.         do {
  1559.             $item $item == null current($similarItems) : next($similarItems);
  1560.             if (false === $item)
  1561.                 return $result;
  1562.             $result $listMethod($item);
  1563.         } while ($result->count() == 0);
  1564.         return $result;
  1565.     }
  1566.     private function shouldShowHomepageCityListingsBlock(City $cityint $pagebool $subRequest): bool
  1567.     {
  1568.         if ($page !== 1) {
  1569.             return false;
  1570.         }
  1571.         if ($subRequest) {
  1572.             return true;
  1573.         }
  1574.         return !$city->equals($this->parameterBag->get('default_city'));
  1575.     }
  1576.     protected function getCurrentPageNumber(): int
  1577.     {
  1578.         $page = (int) $this->requestStack->getCurrentRequest()?->get($this->pageParameter1);
  1579.         if ($page 1) {
  1580.             $page 1;
  1581.         }
  1582.         return $page;
  1583.     }
  1584.     protected function render(string $view, array $parameters = [], Response $response null): Response
  1585.     {
  1586.         $this->listingService->setCurrentListingPage($parameters['profiles']);
  1587.         $requestAttrs $this->requestStack->getCurrentRequest();
  1588.         $listing $requestAttrs->get('_controller');
  1589.         $listing is_array($listing) ? $listing[count($listing) - 1] : $listing;
  1590.         $listing preg_replace('/[^:]+::/'''$listing);
  1591.         $listingParameters $requestAttrs->get('_route_params');
  1592.         $listingParameters is_array($listingParameters) ? $listingParameters : [];
  1593.         $mainRequestHasPageParam = isset(($this->requestStack->getMainRequest()->get('_route_params') ?? [])['page']);
  1594.         if ($this->requestStack->getCurrentRequest()->isXmlHttpRequest()) {
  1595.             $view = (
  1596.                 str_starts_with($listing'list')
  1597.                 && 'ProfileList/list.html.twig' === $view
  1598.                 && $mainRequestHasPageParam //isset($listingParameters['page'])
  1599.             )
  1600.                 ? 'ProfileList/list.profiles.html.twig'
  1601.                 $view;
  1602.             return $this->prepareForXhr(parent::render($view$parameters$response));
  1603.             //return $this->getJSONResponse($parameters);
  1604.         } else {
  1605.             $parameters array_merge($parameters, [
  1606.                 'listing' => $listing,
  1607.                 'listing_parameters' => $listingParameters,
  1608.             ]);
  1609.             return parent::render($view$parameters$response);
  1610.         }
  1611.     }
  1612.     private function listActiveWithinCityOrderedByStatusWithSpecAvoidingTopPlacementLimited(
  1613.         City $city,
  1614.         ?Filter $spec,
  1615.         array $additionalSpecs null,
  1616.         array $genders = [Genders::FEMALE],
  1617.         int $limit 0,
  1618.     ): array|Page {
  1619.         return $this->profileList->listActiveWithinCityOrderedByStatusWithSpecLimited($city$spec$additionalSpecs$genderstrue$limit);
  1620.     }
  1621.     private function listRandomSinglePage(
  1622.         City $city,
  1623.         ?string $country,
  1624.         ?Filter $spec,
  1625.         ?array $additionalSpecs,
  1626.         bool $active,
  1627.         ?bool $masseur false,
  1628.         array $genders = [Genders::FEMALE]
  1629.     ): Page {
  1630.         return $this->profileList->listRandom($city$country$spec$additionalSpecs$active$masseur$genderstrue);
  1631.     }
  1632.     private function shuffleProfilesOnPage(Page $result): Page
  1633.     {
  1634.         $profiles iterator_to_array($result->getIterator());
  1635.         if(count($profiles) > 1) {
  1636.             shuffle($profiles);
  1637.         }
  1638.         return new FakeORMQueryPage(
  1639.             $result->getCurrentOffset(),
  1640.             $result->getCurrentPage(),
  1641.             $result->getCurrentLimit(),
  1642.             $result->totalCount(),
  1643.             $profiles
  1644.         );
  1645.     }
  1646.     /**
  1647.      * Достает из списка анкет их id с учетом совместимости разных форматов данных
  1648.      */
  1649.     private function extractProfileIds(array $profiles): array
  1650.     {
  1651.         $ids array_map(static function ($item) {
  1652.             /**
  1653.              * - array - данные из микросервиса ротации через API
  1654.              * - Profile::getId() - полноценная сущность анкеты
  1655.              * - ProfileListingReadModel::$id - read-model анкеты
  1656.              */
  1657.             return is_array($item) ? $item['id'] : ($item?->id ?? $item?->getId());
  1658.         }, $profiles);
  1659.         return array_filter($ids); // remove null values
  1660.     }
  1661. //    protected function getJSONResponse(array $parameters)
  1662. //    {
  1663. //        $request = $this->request;
  1664. //        $data = json_decode($request->getContent(), true);
  1665. //
  1666. //        $imageSize = !empty($data['imageSize']) ? $data['imageSize'] : "357x500";
  1667. //
  1668. //        /** @var FakeORMQueryPage $queryPage */
  1669. //        $queryPage = $parameters['profiles'];
  1670. //
  1671. //        $profiles = array_map(function(ProfileListingReadModel $profile) use ($imageSize) {
  1672. //            $profile->stations = array_values($profile->stations);
  1673. //            $profile->avatar['path'] = $this->responsiveAssetsService->getResponsiveImageUrl($profile->avatar['path'], 'profile_media', $imageSize, 'jpg');
  1674. //            $profile->uri = $this->generateUrl('profile_preview.page', ['city' => $profile->city->uriIdentity, 'profile' => $profile->uriIdentity]);
  1675. //            return $profile;
  1676. //        }, $queryPage->getArray());
  1677. //
  1678. //        return new JsonResponse([
  1679. //            'profiles' => $profiles,
  1680. //            'currentPage' => $queryPage->getCurrentPage(),
  1681. //        ], Response::HTTP_OK);
  1682. //    }
  1683. }