mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: identify tld type
This commit is contained in:
45
migrations/Version20240724201612.php
Normal file
45
migrations/Version20240724201612.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240724201612 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TEMPORARY TABLE __temp__tld AS SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM tld');
|
||||||
|
$this->addSql('DROP TABLE tld');
|
||||||
|
$this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, contract_terminated BOOLEAN DEFAULT NULL, date_of_contract_signature DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, delegation_date DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, registry_operator VARCHAR(255) DEFAULT NULL, removal_date DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, specification13 BOOLEAN DEFAULT NULL, type VARCHAR(10) NOT NULL, PRIMARY KEY(tld))');
|
||||||
|
$this->addSql('INSERT INTO tld (tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type) SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM __temp__tld');
|
||||||
|
$this->addSql('DROP TABLE __temp__tld');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE TEMPORARY TABLE __temp__tld AS SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM tld');
|
||||||
|
$this->addSql('DROP TABLE tld');
|
||||||
|
$this->addSql('CREATE TABLE tld (tld VARCHAR(63) NOT NULL, contract_terminated BOOLEAN DEFAULT NULL, date_of_contract_signature DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, delegation_date DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, registry_operator VARCHAR(255) DEFAULT NULL, removal_date DATE DEFAULT NULL --(DC2Type:date_immutable)
|
||||||
|
, specification13 BOOLEAN DEFAULT NULL, type VARCHAR(10) DEFAULT NULL, PRIMARY KEY(tld))');
|
||||||
|
$this->addSql('INSERT INTO tld (tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type) SELECT tld, contract_terminated, date_of_contract_signature, delegation_date, registry_operator, removal_date, specification13, type FROM __temp__tld');
|
||||||
|
$this->addSql('DROP TABLE __temp__tld');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -68,7 +68,7 @@ class Tld
|
|||||||
#[Groups(["tld:list", "tld:item"])]
|
#[Groups(["tld:list", "tld:item"])]
|
||||||
private ?bool $specification13 = null;
|
private ?bool $specification13 = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 10, nullable: true, enumType: TldType::class)]
|
#[ORM\Column(length: 10, enumType: TldType::class)]
|
||||||
#[Groups(["tld:item"])]
|
#[Groups(["tld:item"])]
|
||||||
private ?TldType $type = null;
|
private ?TldType $type = null;
|
||||||
|
|
||||||
|
|||||||
@@ -339,15 +339,13 @@ readonly class RDAPService
|
|||||||
$tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]);
|
$tldEntity = $this->tldRepository->findOneBy(['tld' => $tld]);
|
||||||
if ($tldEntity === null) $tldEntity = new Tld();
|
if ($tldEntity === null) $tldEntity = new Tld();
|
||||||
|
|
||||||
if ($tldEntity->getType() === null) {
|
$type = $this->getTldType($tld);
|
||||||
$type = $this->getTldType($tld);
|
if ($type !== null) {
|
||||||
if ($type !== null) {
|
$tldEntity->setType($type);
|
||||||
$tldEntity->setType($type);
|
} elseif ($tldEntity->isContractTerminated() === null) {
|
||||||
} elseif ($tldEntity->isContractTerminated() === null) {
|
$tldEntity->setType(TldType::ccTLD);
|
||||||
$tldEntity->setType(TldType::ccTLD);
|
} else {
|
||||||
} else {
|
$tldEntity->setType(TldType::gTLD);
|
||||||
$tldEntity->setType(TldType::gTLD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->em->persist($tldEntity);
|
$this->em->persist($tldEntity);
|
||||||
|
|||||||
Reference in New Issue
Block a user