src/Controller/ProfilePreviewController.php line 68

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-03-19
  5.  * Time: 22:20
  6.  */
  7. namespace App\Controller;
  8. use App\Entity\Location\City;
  9. use App\Entity\Profile\Profile;
  10. use App\Entity\ServiceGroups;
  11. use App\Repository\ServiceRepository;
  12. use App\Service\ModerationService;
  13. use App\Service\NearestProfiles;
  14. use App\Service\ProfileList;
  15. use App\Specification\ElasticSearch\Spec;
  16. use Carbon\CarbonImmutable;
  17. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  18. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
  19. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  20. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  21. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  22. use Symfony\Component\HttpFoundation\Response;
  23. use Symfony\Component\HttpKernel\Exception\GoneHttpException;
  24. #[Cache(maxage600, public: true)]
  25. class ProfilePreviewController extends AbstractController
  26. {
  27.     use ProfileCommentsTrait;
  28.     #[ParamConverter("city"converter"city_converter")]
  29.     #[Entity("profile"expr"repository.ofUriIdentityWithinCity(profile, city)")]
  30.     public function page(
  31.         ServiceRepository     $serviceRepositoryCity $cityProfile $profileModerationService $moderationService,
  32.         ParameterBagInterface $parameterBagNearestProfiles $nearestProfiles,
  33.     ): Response
  34.     {
  35.         //  DMCA hard delete — всегда 404
  36.         if ($profile->isHardDeleted()) {
  37.             throw $this->createNotFoundException();
  38.         }
  39.         $showHttp200FromDate CarbonImmutable::createFromTimeString($parameterBag->get('app.profile.page.deleted_profile_http_200_starting_from'));
  40.         if ($profile->isDeleted() && $profile->getDeletedAt() < $showHttp200FromDate) {
  41.             throw new GoneHttpException();
  42.         }
  43.         //$entityManager->getFilters()->enable('not_deleted_profile_filter');
  44.         if ($profile->isModerationRejected()) {
  45.             //показываем
  46.         } else if (false == $moderationService->isProfileEligibleToShowByModeration($profile)) {
  47.             throw $this->createNotFoundException();
  48.         }
  49.         $services $serviceRepository->allIndexedByGroup();
  50.         $parameters = [
  51.             'profile' => $profile,
  52.             'services' => $services,
  53.             'masseurExcludeServiceGroups' => [
  54.                 ServiceGroups::SEXServiceGroups::EXTREMEServiceGroups::BDSMServiceGroups::MISC,
  55.             ],
  56.             'recommendationSpec' => Spec::andX(),
  57.             'rating' => $this->countAverageRating($profile),
  58.             'nearest_profiles' => $nearestProfiles->getNearestProfiles($profile6),
  59.         ];
  60.         return $this->render('ProfilePreview/page.html.twig'$parameters);
  61.     }
  62. }