Guest User

Untitled

a guest
Jul 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. /**
  2. * @ORMColumn(type="date", nullable=true)
  3. */
  4. private $isPublished;
  5.  
  6. /**
  7. * @Route("/", methods="GET|POST")
  8. * @param Request $request
  9. * @return Response
  10. */
  11. public function index(Request $request): Response {
  12.  
  13. $cookie = 'Bienvenue sur mon site web';
  14. setcookie('Al-houria.com', $cookie, time()+31536000, null, null, false, true);
  15.  
  16. $em = $this->get('doctrine.orm.entity_manager');
  17. $dql = "SELECT a FROM App:Articles a ORDER BY a.createdAt DESC";
  18. $query = $em->createQuery($dql);
  19.  
  20. $paginator = $this->get('knp_paginator');
  21. $pagination = $paginator->paginate(
  22. $query, /* query NOT result */
  23. $request->query->getInt('page', 1)/*page number*/,
  24. 10/*limit per page*/
  25. );
  26.  
  27.  
  28. return $this->render('index.html.twig', [
  29. 'title' => 'Parce qu'écrire est une liberté',
  30. 'description' => 'Bienvenue sur Al-Houria.fr le blog culture et humeur d'une passionnée du Moyen Orient.',
  31. 'keywords' => 'Blog, Al-houria, Articles, Mondes, Actualité, Culture',
  32. 'pagination' => $pagination
  33. ]);
  34.  
  35. }
Add Comment
Please, Sign In to add comment