src/Controller/ProfileListController.php line 190

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