<?php
namespace App\Form\Activity;

use App\Form\AbstractFormManager;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use App\Repository\ActivityRepository;
use App\Entity\ActivityEntity;

class ActivityDeleteForm extends AbstractFormManager
{

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

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

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