src/Controller/BlogController.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\Blog;
  4. use App\Entity\Post;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Doctrine\Persistence\ManagerRegistry;
  8. class BlogController extends AbstractController
  9. {
  10.     
  11.     public function index(ManagerRegistry $doctrine)
  12.     {
  13.       $blog $doctrine->getRepository(Blog::class)->findBy(array(), array('id' => 'desc'));
  14.       $blog_new $doctrine->getRepository(Blog::class)->findBy(array(), array('id' => 'desc'),6,0);
  15.       return $this->render('blog/index.html.twig',['blog'=>$blog,'blog_new'=>$blog_new]);
  16.     }
  17.     public function detail(ManagerRegistry $doctrine,$id,$name)
  18.     {
  19.       $blog $doctrine->getRepository(Blog::class)->find($id);
  20.       $blog_new $doctrine->getRepository(Blog::class)->findBy(array(), array('id' => 'desc'),6,0);
  21.     
  22.       return $this->render('blog/detail.html.twig',['key'=>$blog,'blog_new'=>$blog_new,'id'=>$id]);
  23.     }
  24. }