src/Controller/Frontend/PhoneBookController.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Frontend;
  3. use App\Controller\BaseController;
  4. use App\Form\Frontend\PhoneBookSearchType;
  5. use App\Repository\EnterpriseRepository;
  6. use Knp\Component\Pager\PaginatorInterface;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class PhoneBookController extends BaseController
  11. {
  12.     #[Route('/phone/book'name'customer_phone_book'methods: ['GET''POST'])]
  13.     public function index(
  14.         Request $request,
  15.         EnterpriseRepository $repository,
  16.         PaginatorInterface $paginator
  17.     ): Response
  18.     {
  19.         $search null;
  20.         $form $this->createForm(PhoneBookSearchType::class);
  21.         $form->handleRequest($request);
  22.         if ($form->isSubmitted() && $form->isValid()) {
  23.             $search $form->get('search')->getData();
  24.         }
  25.         $query $repository->findMemberOnPhoneBookQuery($search);
  26.         $firms $paginator->paginate(
  27.             $query,
  28.             $request->query->getInt('page'1),
  29.             self::ITEM_PER_PAGE
  30.         );
  31.         return $this->renderForm('frontend/phone_book/index.html.twig', [
  32.             'controller_name' => 'PhoneBookController',
  33.             'menu' => 'phone-book',
  34.             'firms' => $firms,
  35.             'form' => $form
  36.         ]);
  37.     }
  38. }