src/Controller/MainController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\About;
  4. use App\Entity\Blog;
  5. use App\Entity\Header;
  6. use App\Entity\Projects;
  7. use App\Entity\Testimony;
  8. use App\Entity\Tranings;
  9. use App\Repository\SectionTitleRepository;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. class MainController extends AbstractController {
  15.     private $entityManager;
  16.     public function __construct(EntityManagerInterface $entityManager) {
  17.         $this->entityManager = $entityManager;
  18.     }
  19.     /**
  20.      * @Route("/", name="app_main")
  21.      */
  22.     public function index(SectionTitleRepository $sectionRepo): Response {
  23.         $headers = $this->entityManager->getRepository(Header::class)->findByIsActive(1);
  24.         $about = $this->entityManager->getRepository(About::class)->findByIsActive(1);
  25.         $traning = $this->entityManager->getRepository(Tranings::class)->findByIsActive(1);
  26.         $blog = $this->entityManager->getRepository(Blog::class)->findByIsActive(1);
  27.         $projects = $this->entityManager->getRepository(Projects::class)->findByIsActive(1);
  28.         $testimony = $this->entityManager->getRepository(Testimony::class)->findByIsActive(1);
  29.         $sectionTitle = $sectionRepo->findTitleByTag('projects_index');
  30.         $blogIndex = $sectionRepo->findTitleByTag('blog_index');
  31.         return $this->render('main/index.html.twig', [
  32.                     'headers' => $headers,
  33.                     'abouts' => $about,
  34.                     'tranings' => $traning,
  35.                     'projectstitle' => $sectionTitle,
  36.                     'blogTitle' => $blogIndex,
  37.                     'projects' => $projects,
  38.                     'blogs' => $blog,
  39.                     'testimonies' => $testimony,
  40.         ]);
  41.     }
  42. }