Skip to content
Snippets Groups Projects
Commit 7bb55cc3 authored by Адлан Шамавов's avatar Адлан Шамавов
Browse files

fix

parent 8ee9ca86
No related branches found
No related tags found
1 merge request!5Ptps controller 5
...@@ -7,7 +7,8 @@ use App\Requests\{ ...@@ -7,7 +7,8 @@ use App\Requests\{
SortPriceRequest, SortPriceRequest,
SearchRequest, SearchRequest,
UniqElementsRequest, UniqElementsRequest,
MenuRequest MenuRequest,
HowDaysToNyRequest
}; };
use DateTimeImmutable; use DateTimeImmutable;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
...@@ -48,21 +49,12 @@ class HomeController extends AbstractController ...@@ -48,21 +49,12 @@ class HomeController extends AbstractController
return $this->json($result); return $this->json($result);
} }
#[Route( #[Route('/howDaysToNy', name: 'howDaysToNy', methods: ['GET'])]
'/howDaysToNy/{day}/{month}/{year}', public function howDaysToNy(HowDaysToNyRequest $request): Response
name: 'howDaysToNy',
requirements: [
'day' => '(?<!-)(?<!\d)\d+',
'month' => '(?<!-)(?<!\d)\d+',
'year' => '(?<!-)(?<!\d)\d+'
],
methods: ['GET']
)]
public function howDaysToNy(int $day, int $month, int $year): Response
{ {
$dateAsString = $year . "-" . $month . "-" . $day; $date = $request->getRequest()->get('date');
try { try {
$result = $this->functions->howDaysToNy(new DateTimeImmutable($dateAsString)); $result = $this->functions->howDaysToNy(new DateTimeImmutable($date));
} catch (\Exception $e) { } catch (\Exception $e) {
return new Response($e->getMessage()); return new Response($e->getMessage());
} }
......
<?php
namespace App\Requests;
use Symfony\Component\Validator\Constraints as Assert;
class HowDaysToNyRequest extends BaseRequest
{
#[Assert\Type('date')]
public $date;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment