Skip to content
DiffDaysController.php 846 B
Newer Older
Akex's avatar
Akex committed
<?php

namespace App\Controller;

use App\Actions\DiffDaysAction;
use App\Requests\DiffDaysRequest;
Akex's avatar
Akex committed
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class DiffDaysController extends AbstractController
{
    /**
     * Контроллер вернет кол-во дней между датами
     * @param DiffDaysRequest $request
     * @param DiffDaysAction $action
Akex's avatar
Akex committed
     * @return Response
     */
    #[Route('/diff/days', name: 'app_diff_days', methods: ['POST'])]
    public function index(DiffDaysRequest $request, DiffDaysAction $action): Response
Akex's avatar
Akex committed
    {
        $array = $request->serialise();
        return new JsonResponse($action->act($array[0], $array[1]));
Akex's avatar
Akex committed
    }
}