src/Flexy/FrontBundle/Controller/VendorController.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Flexy\FrontBundle\Controller;
  3. use App\Flexy\FrontBundle\Repository\ProductFrontRepository;
  4. use App\Flexy\ProductBundle\Repository\ProductRepository;
  5. use App\Flexy\ShopBundle\Entity\Vendor\Vendor;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Knp\Component\Pager\PaginatorInterface;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. #[Route('/shop/vendors')]
  13. class VendorController extends AbstractController
  14. {
  15.     #[Route('/single-vendor/{id}'name'single_vendor')]
  16.     public function single(
  17.         Vendor $vendor,
  18.     ProductFrontRepository $productFrontRepository,
  19.     EntityManagerInterface $em
  20.     PaginatorInterface $paginator
  21.     Request $request
  22.     ): Response
  23.     {
  24.         $dql   "SELECT product FROM App\Flexy\ShopBundle\Entity\Product\Product product LEFT  JOIN product.vendor vendor WHERE vendor.id =  ".$vendor->getId()." AND  product.isPublished = TRUE";
  25.         $query $em->createQuery($dql);
  26.         
  27.         $pagination $paginator->paginate(
  28.             $query/* query NOT result */
  29.             $request->query->getInt('page'1), /*page number*/
  30.             10 /*limit per page*/
  31.         );
  32.         return $this->render('@Flexy\FrontBundle/templates/vendors/singleVendor.html.twig', [
  33.             'vendor' => $vendor,
  34.             'products'=>$pagination
  35.         ]);
  36.     }
  37. }