<?php

declare(strict_types=1);

/*
 * Chill is a software for social workers
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Chill\TicketBundle\Controller;

use Chill\TicketBundle\Entity\Ticket;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Twig\Environment;

class EditTicketController
{
    private readonly string $personPerTicket;

    public function __construct(
        private readonly Environment $templating,
        ParameterBagInterface $parameterBag,
    ) {
        $this->personPerTicket = $parameterBag->get('chill_ticket')['ticket']['person_per_ticket'];
    }

    #[Route('/{_locale}/ticket/ticket/{id}/edit', name: 'chill_ticket_ticket_edit')]
    public function __invoke(
        Ticket $ticket,
    ): Response {
        return new Response(
            $this->templating->render(
                '@ChillTicket/Ticket/edit.html.twig',
                [
                    'ticket' => $ticket,
                    'personPerTicket' => $this->personPerTicket,
                ]
            )
        );
    }
}
