<?php

namespace App\Controller\Frontend;

use App\Entity\Dream;
use App\Entity\ProjectBoost;
use App\Entity\ProjectInspiring;
use App\Entity\Revolt;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class DefaultController extends AbstractController
{
    protected EntityManagerInterface $em;

    public function __construct(
        EntityManagerInterface $em
    ) {
        $this->em = $em;
    }

    protected function countContrib(): int
    {
        $dreamRepository = $this->em->getRepository(Dream::class);
        $revoltRepository = $this->em->getRepository(Revolt::class);
        $projectBoostRepository = $this->em->getRepository(ProjectBoost::class);
        $projectInspiringRepository = $this->em->getRepository(ProjectInspiring::class);

        $dream = count($dreamRepository->findAll());
        $revolt = count($revoltRepository->findAll());
        $projectBoost = count($projectBoostRepository->findAll());
        $projectInspiring = count($projectBoostRepository->findAll());

        $nbContrib = $dream + $revolt + $projectBoost + $projectInspiring;

        return $nbContrib;
    }

}