src/Controller/ProfilePreviewController.php line 36

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\Event\Profile\ProfileViewEvent;
  12. use App\Repository\ServiceRepository;
  13. use App\Service\ModerationService;
  14. use App\Service\NearestProfiles;
  15. use App\Service\ProfileList;
  16. use App\Specification\ElasticSearch\Spec;
  17. use Carbon\CarbonImmutable;
  18. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
  19. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Entity;
  20. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  21. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  22. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  23. use Symfony\Component\HttpFoundation\Response;
  24. use Symfony\Component\HttpKernel\Exception\GoneHttpException;
  25. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  26. #[Cache(maxage600, public: true)]
  27. class ProfilePreviewController extends AbstractController
  28. {
  29.     use ProfileCommentsTrait;
  30.     #[ParamConverter("city"converter"city_converter")]
  31.     #[Entity("profile"expr"repository.ofUriIdentityWithinCity(profile, city)")]
  32.     public function page(
  33.         ServiceRepository     $serviceRepositoryCity $cityProfile $profileModerationService $moderationService,
  34.         ParameterBagInterface $parameterBagEventDispatcherInterface $eventDispatcherNearestProfiles $nearestProfiles,
  35.     ): Response
  36.     {
  37.         //  DMCA hard delete — всегда 404
  38.         if ($profile->isHardDeleted()) {
  39.             throw $this->createNotFoundException();
  40.         }
  41.         $showHttp200FromDate CarbonImmutable::createFromTimeString($parameterBag->get('app.profile.page.deleted_profile_http_200_starting_from'));
  42.         if ($profile->isDeleted() && $profile->getDeletedAt() < $showHttp200FromDate) {
  43.             throw new GoneHttpException();
  44.         }
  45.         //$entityManager->getFilters()->enable('not_deleted_profile_filter');
  46.         if ($profile->isModerationRejected()) {
  47.             //показываем
  48.         } else if (false == $moderationService->isProfileEligibleToShowByModeration($profile)) {
  49.             throw $this->createNotFoundException();
  50.         }
  51.         $services $serviceRepository->allIndexedByGroup();
  52.         //вынесено d ProfileCtrController для ajax
  53.         //$eventDispatcher->dispatch(new ProfileViewEvent($profile->getId()), ProfileViewEvent::NAME);
  54.         $parameters = [
  55.             'profile' => $profile,
  56.             'services' => $services,
  57.             'masseurExcludeServiceGroups' => [
  58.                 ServiceGroups::SEXServiceGroups::EXTREMEServiceGroups::BDSMServiceGroups::MISC,
  59.             ],
  60.             'recommendationSpec' => Spec::andX(),
  61.             'rating' => $this->countAverageRating($profile),
  62.             'nearest_profiles' => $nearestProfiles->getNearestProfiles($profile6),
  63.         ];
  64.         return $this->render('ProfilePreview/page.html.twig'$parameters);
  65.     }
  66. }