<?php
namespace App\Controller;
use App\Entity\About;
use App\Entity\Blog;
use App\Entity\Header;
use App\Entity\Projects;
use App\Entity\Testimony;
use App\Entity\Tranings;
use App\Repository\SectionTitleRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class MainController extends AbstractController {
private $entityManager;
public function __construct(EntityManagerInterface $entityManager) {
$this->entityManager = $entityManager;
}
/**
* @Route("/", name="app_main")
*/
public function index(SectionTitleRepository $sectionRepo): Response {
$headers = $this->entityManager->getRepository(Header::class)->findByIsActive(1);
$about = $this->entityManager->getRepository(About::class)->findByIsActive(1);
$traning = $this->entityManager->getRepository(Tranings::class)->findByIsActive(1);
$blog = $this->entityManager->getRepository(Blog::class)->findByIsActive(1);
$projects = $this->entityManager->getRepository(Projects::class)->findByIsActive(1);
$testimony = $this->entityManager->getRepository(Testimony::class)->findByIsActive(1);
$sectionTitle = $sectionRepo->findTitleByTag('projects_index');
$blogIndex = $sectionRepo->findTitleByTag('blog_index');
return $this->render('main/index.html.twig', [
'headers' => $headers,
'abouts' => $about,
'tranings' => $traning,
'projectstitle' => $sectionTitle,
'blogTitle' => $blogIndex,
'projects' => $projects,
'blogs' => $blog,
'testimonies' => $testimony,
]);
}
}