<?php
namespace App\Controller;

use App\Entity\ActivityEntity;
use App\Entity\TaskEntity;
use App\Repository\ActivityRepository;
use App\Repository\TaskRepository;
use Symfony\Component\HttpFoundation\Response;

/**
 * Controller for main view
 */
class MainController extends AbstractExtendedController
{

    /**
     * Home page
     *
     * @return Response
     */
    public function home(): Response
    {
        // Get repositories
        $entityManager = $this->getDoctrine()->getManager();
        /** @var ActivityRepository $activityRepository */
        $activityRepository = $entityManager->getRepository(ActivityEntity::class);
        /** @var TaskRepository $taskRepository */
        $taskRepository = $entityManager->getRepository(TaskEntity::class);

        // Get activities
        $activities = $activityRepository->findActiveFollowed();

        // Get tasks
        $tasks = $taskRepository->findActiveFollowed();

        return $this->render('home.html.twig', [
            'activities' => $activities,
            'tasks' => $tasks,
        ]);
    }
}