mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: add RDAP response dto
This commit is contained in:
31
src/State/DomainRdapResponseProvider.php
Normal file
31
src/State/DomainRdapResponseProvider.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\State;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\Entity\Domain;
|
||||
use App\Entity\RdapResponse\DomainRdapResponse;
|
||||
use App\Repository\DomainRepository;
|
||||
use App\Service\RDAPService;
|
||||
|
||||
readonly class DomainRdapResponseProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private DomainRepository $domainRepository,
|
||||
private AutoRegisterDomainProvider $autoRegisterDomainProvider,
|
||||
) {
|
||||
}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
|
||||
{
|
||||
$this->autoRegisterDomainProvider->provide($operation, $uriVariables, $context);
|
||||
|
||||
$idnDomain = RDAPService::convertToIdn($uriVariables['ldhName']);
|
||||
|
||||
/** @var Domain $domain */
|
||||
$domain = $this->domainRepository->findOneBy(['ldhName' => $idnDomain]);
|
||||
|
||||
return new DomainRdapResponse($domain);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user