<?php
namespace App\Form\Actors;

use App\Entity\ActorEntity;
use App\Form\AbstractFormManager;
use App\Repository\ActorRepository;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class ActorDeleteForm extends AbstractFormManager
{

    /**
     * Get the actor entity
     *
     * @param ActorRepository $actorRepository
     * @return ActorEntity|null
     */
    public function getActor(ActorRepository $actorRepository): ?ActorEntity
    {
        $data = $this->form->getData();
        return $actorRepository->find($data['id']);
    }

    /**
     * {@inheritdoc}
     */
    public function getTemplate(): string
    {
        return '_includes/html/form/actors/delete.html.twig';
    }

    /**
     * {@inheritdoc}
     */
    protected function addFields($formBuilder, $options): void
    {
        $formBuilder->add('id', HiddenType::class)->add('submit', SubmitType::class);
    }
}