<?php

namespace App\Controller;

use App\Entity\Dream\Dream;
use App\Entity\ProjectBoost\ProjectBoost;
use App\Entity\ProjectInspiring\ProjectInspiring;
use App\Entity\Revolt\Revolt;
use Doctrine\ORM\EntityManagerInterface;
use Lc\PietroBundle\Controller\AbstractController as PietroAbstractController;

class AbstractController extends PietroAbstractController
{
    use ControllerTrait;
    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;
    }
}