<?php

/*
 * This file is part of the Serenity package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Controller\Site;

use CpCreation\VitiCore\Contact\Repository\ContactRepository;
use CpCreation\VitiCore\Contact\Repository\LabelRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

final class FooterController extends AbstractController
{
    public function __construct(
        private readonly ContactRepository $contactRepository,
        private readonly LabelRepository $labelRepository,
    ) {
    }

    /**
     * @throws \Doctrine\ORM\NonUniqueResultException
     */
    public function index(): Response
    {
        $contact = $this->contactRepository->findOne();
        $labels = $this->labelRepository->findBy([], ['position' => 'ASC']);

        return $this->render('_footer.html.twig', [
            'contact' => $contact,
            'labels' => $labels,
        ]);
    }
}
