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\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.         $showHttp200FromDate CarbonImmutable::createFromTimeString($parameterBag->get('app.profile.page.deleted_profile_http_200_starting_from'));
  38.         if($profile->isDeleted() && $profile->getDeletedAt() < $showHttp200FromDate) {
  39.             throw new GoneHttpException();
  40.         }
  41.         //$entityManager->getFilters()->enable('not_deleted_profile_filter');
  42.         if($profile->isModerationRejected()) {
  43.             //показываем
  44.         } else if (false == $moderationService->isProfileEligibleToShowByModeration($profile)) {
  45.             throw $this->createNotFoundException();
  46.         }
  47.         $services $serviceRepository->allIndexedByGroup();
  48.         //вынесено d ProfileCtrController для ajax
  49.         //$eventDispatcher->dispatch(new ProfileViewEvent($profile->getId()), ProfileViewEvent::NAME);
  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. }