<?php
/**
* Created by simpson <simpsonwork@gmail.com>
* Date: 2019-03-22
* Time: 15:19
*/
namespace App\Controller;
use App\Entity\Location\City;
use App\Repository\ProfileRepository;
use App\Specification\Profile\ProfileAdBoardPlacement;
use App\Specification\Profile\ProfileIsLocated;
use App\Specification\Profile\ProfileIsMasseur;
use App\Specification\QueryModifier\ProfileAvatar;
use App\Specification\QueryModifier\ProfileOrderedByStatus;
use App\Specification\QueryModifier\ProfilePlacementHiding;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Happyr\DoctrineSpecification\Spec;
use Symfony\Component\HttpFoundation\Response;
class GalleryController extends AbstractController
{
use ExtendedPaginationTrait;
const ENTRIES_ON_PAGE = 30;
public function __construct(
private ProfileRepository $profileRepository
) {}
#[ParamConverter("city", converter: "city_converter")]
public function page(City $city): Response
{
$criteria = Spec::andX(
new ProfileAdBoardPlacement(),
new ProfilePlacementHiding(),
new ProfileAvatar(),
ProfileIsLocated::withinCity($city),
Spec::not(new ProfileIsMasseur()),
new ProfileOrderedByStatus()
);
$result = $this->profileRepository->matchingSpec($criteria);
$profiles = $this->takePage($result, self::ENTRIES_ON_PAGE);
return $this->render('Gallery/list.html.twig', [
'profiles' => $profiles,
]);
}
}