Reviewed-on: #1 Co-authored-by: kevin <kevin@yuno.malio.fr> Co-committed-by: kevin <kevin@yuno.malio.fr>
25 lines
725 B
PHP
25 lines
725 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\State;
|
|
|
|
use ApiPlatform\Metadata\Operation;
|
|
use ApiPlatform\State\ProviderInterface;
|
|
use App\ApiResource\PublicHoliday;
|
|
use App\Service\PublicHolidayServiceInterface;
|
|
|
|
final readonly class PublicHolidayYearProvider implements ProviderInterface
|
|
{
|
|
public function __construct(
|
|
private PublicHolidayServiceInterface $PublicHolidayYearService
|
|
) {}
|
|
|
|
public function provide(Operation $operation, array $uriVariables = [], array $context = []): ?object
|
|
{
|
|
$holidaysDay = $this->PublicHolidayYearService->getHolidaysDayByYears($uriVariables['zone'], $uriVariables['years']);
|
|
|
|
return $holidaysDay ? new PublicHoliday($holidaysDay) : null;
|
|
}
|
|
}
|