src/Controller/SubscribersController.php line 37

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. use Symfony\Component\HttpFoundation\RedirectResponse;
  9. use OlaSoft\Common;
  10. use App\Entity\Subscribers;
  11. /**
  12.  * @Route("/os-admin/subscribers")
  13.  */
  14. class SubscribersController extends AbstractController
  15. {    
  16.     public function __construct(ManagerRegistry $doctrine){
  17.         $this->doctrine =  $doctrine;
  18.     }
  19.     
  20.     private $doctrine;
  21.     
  22.     public function getDoctrine()
  23.     {
  24.         return $this->doctrine;
  25.     }
  26.     
  27.     /**
  28.      * @Route("/", name="subscribers-admin")
  29.      * @Route("/page/{offset}", name="subscribers-admin-page")
  30.      * @Route("/search/{keywords}/page/{offset}/",name="subscribers-search-admin-page")
  31.      * @Route("/search/{keywords}/",name="subscribers-search-admin")
  32.      */
  33.     public function admin(Request $request$keywords=null,$offset=1)
  34.     {
  35.         $offset--;
  36.         $limit 500;
  37.         $of=$offset*$limit;
  38.         $em $this->getDoctrine()->getManager();
  39.         $list$em->getRepository(Subscribers::class)->findBy([],['date'=>'desc'],$limit,$of);
  40.         $count=$em->getRepository(Subscribers::class)->count([]);
  41.         
  42.         $ajax $request->isXmlHttpRequest();
  43.         $response $this->render('Admin\index.html.twig',[
  44.             'messages' => $list,
  45.             'noAddBtn' => true,
  46.             'ajax'=>$ajax,
  47.             'count'=>$count,
  48.             'offset'=>$offset,
  49.             'title'=>'Gestion des inscriptions reçus',
  50.             'subtitle'=>'Liste de toutes les inscriptions'
  51.         ]);
  52.         return $ajax 
  53.             new Response(\json_encode([
  54.                 'content'=>$response->getContent(),
  55.             'title'=>'Gestion des inscriptions reçus',
  56.             'subtitle'=>'Liste de toutes les inscriptions'
  57.             ]))
  58.         : $response;
  59.     }
  60.     
  61.     
  62. }