mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: persist and flush entity
This commit is contained in:
@@ -33,20 +33,22 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||||||
class TestController extends AbstractController
|
class TestController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
#[Route(path: '/test', name: 'test')]
|
#[Route(path: '/test/{fqdn}', name: 'test')]
|
||||||
public function testRoute(EntityRepository $entityRepository,
|
public function testRoute(
|
||||||
DomainRepository $domainRepository,
|
string $fqdn,
|
||||||
DomainEventRepository $domainEventRepository,
|
EntityRepository $entityRepository,
|
||||||
NameserverRepository $nameserverRepository,
|
DomainRepository $domainRepository,
|
||||||
NameserverEntityRepository $nameserverEntityRepository,
|
DomainEventRepository $domainEventRepository,
|
||||||
EntityEventRepository $entityEventRepository,
|
NameserverRepository $nameserverRepository,
|
||||||
DomainEntityRepository $domainEntityRepository,
|
NameserverEntityRepository $nameserverEntityRepository,
|
||||||
EntityManagerInterface $em
|
EntityEventRepository $entityEventRepository,
|
||||||
|
DomainEntityRepository $domainEntityRepository,
|
||||||
|
EntityManagerInterface $em
|
||||||
): Response
|
): Response
|
||||||
{
|
{
|
||||||
$rdap = new RDAPClient(['domain' => 'https://rdap.nic.fr/domain/']);
|
$rdap = new RDAPClient(['domain' => 'https://rdap.nic.fr/domain/']);
|
||||||
try {
|
try {
|
||||||
$res = $rdap->domainLookup('maelgangloff.fr', RDAPClient::ARRAY_OUTPUT);
|
$res = $rdap->domainLookup($fqdn, RDAPClient::ARRAY_OUTPUT);
|
||||||
} catch (RDAPWrongRequest $e) {
|
} catch (RDAPWrongRequest $e) {
|
||||||
return new Response(null, Response::HTTP_BAD_REQUEST);
|
return new Response(null, Response::HTTP_BAD_REQUEST);
|
||||||
} catch (ClientExceptionInterface $e) {
|
} catch (ClientExceptionInterface $e) {
|
||||||
@@ -106,6 +108,7 @@ class TestController extends AbstractController
|
|||||||
"domain" => $domain,
|
"domain" => $domain,
|
||||||
"entity" => $entity
|
"entity" => $entity
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($domainEntity === null) $domainEntity = new DomainEntity();
|
if ($domainEntity === null) $domainEntity = new DomainEntity();
|
||||||
|
|
||||||
|
|
||||||
@@ -114,6 +117,8 @@ class TestController extends AbstractController
|
|||||||
->setEntity($entity)
|
->setEntity($entity)
|
||||||
->setRoles(array_map(fn($str): DomainRole => DomainRole::from($str), $rdapEntity['roles'])));
|
->setRoles(array_map(fn($str): DomainRole => DomainRole::from($str), $rdapEntity['roles'])));
|
||||||
|
|
||||||
|
$em->persist($entity);
|
||||||
|
$em->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->persist($domain);
|
$em->persist($domain);
|
||||||
|
|||||||
Reference in New Issue
Block a user