src/Controller/News/NewsController.php line 49

Open in your IDE?
  1. <?php
  2. namespace App\Controller\News;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use App\Entity\Team;
  7. use App\Entity\Role;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. //use App\Form\EquipeType;
  10. class NewsController extends AbstractController
  11. {
  12.     protected $repo;
  13.     public function __construct(EntityManagerInterface $entityManager)
  14.     {
  15.         $this->repo $entityManager->getRepository('App:News');
  16.     }
  17.     /**
  18.      * @Route("/news", name="news_list")
  19.      */
  20.     public function allNews()
  21.     {
  22.         $news $this->repo->findAllNews();
  23.         return $this->render('News/news.html.twig', ['news' => $news]);
  24.     }
  25.     /**
  26.      * @Route("/news/{id}", name="news_card")
  27.      */
  28.     public function oneNews($id null)
  29.     {
  30.         $news $this->repo->findNews($id);
  31.         return $this->render('news/card.html.twig', ['news' => $news]);
  32.     }
  33.     /*
  34.      * Rendered controllers in template
  35.      */
  36.     public function showNewsFront($limit null){
  37.         return $this->render('News/last-x-news.html.twig', ['news_list'=>$this->repo->findLastNews($limit)]);
  38.     }
  39. }