src/Controller/GalleryController.php line 44

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by simpson <simpsonwork@gmail.com>
  4.  * Date: 2019-03-22
  5.  * Time: 15:19
  6.  */
  7. namespace App\Controller;
  8. use App\Entity\Location\City;
  9. use App\Repository\ProfileRepository;
  10. use App\Specification\Profile\ProfileAdBoardPlacement;
  11. use App\Specification\Profile\ProfileIsLocated;
  12. use App\Specification\Profile\ProfileIsMasseur;
  13. use App\Specification\QueryModifier\ProfileAvatar;
  14. use App\Specification\QueryModifier\ProfileOrderedByStatus;
  15. use App\Specification\QueryModifier\ProfilePlacementHiding;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  18. use Happyr\DoctrineSpecification\Spec;
  19. use Symfony\Component\HttpFoundation\Response;
  20. class GalleryController extends AbstractController
  21. {
  22.     use ExtendedPaginationTrait;
  23.     const ENTRIES_ON_PAGE 30;
  24.     public function __construct(
  25.         private ProfileRepository $profileRepository
  26.     ) {}
  27.     #[ParamConverter("city"converter"city_converter")]
  28.     public function page(City $city): Response
  29.     {
  30.         $criteria Spec::andX(
  31.             new ProfileAdBoardPlacement(),
  32.             new ProfilePlacementHiding(),
  33.             new ProfileAvatar(),
  34.             ProfileIsLocated::withinCity($city),
  35.             Spec::not(new ProfileIsMasseur()),
  36.             new ProfileOrderedByStatus()
  37.         );
  38.         $result $this->profileRepository->matchingSpec($criteria);
  39.         $profiles $this->takePage($resultself::ENTRIES_ON_PAGE);
  40.         return $this->render('Gallery/list.html.twig', [
  41.             'profiles' => $profiles,
  42.         ]);
  43.     }
  44. }