<?php
namespace App\Form\Task;

use App\Entity\TaskEntity;
use App\Form\AbstractFormManager;
use App\Repository\TaskRepository;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class TaskDeleteForm extends AbstractFormManager
{

    /**
     * Get the activity entity
     *
     * @param TaskRepository $activityRepository
     * @return TaskEntity|null
     */
    public function getTask(TaskRepository $taskRepository): ?TaskEntity
    {
        $data = $this->form->getData();
        return $taskRepository->find($data['id']);
    }

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

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