feat: add delete property on DomainEntity

This commit is contained in:
Maël Gangloff
2024-09-04 18:06:02 +02:00
parent 7bdb289461
commit 689ad51e3a
5 changed files with 59 additions and 23 deletions

View File

@@ -27,13 +27,13 @@ class DomainEntity
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
private array $roles = [];
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
#[ORM\Column]
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
private ?\DateTimeImmutable $updatedAt = null;
private ?bool $deleted;
public function __construct()
{
$this->updatedAt = new \DateTimeImmutable('now');
$this->deleted = false;
}
public function getDomain(): ?Domain
@@ -75,22 +75,15 @@ class DomainEntity
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
public function getDeleted(): ?bool
{
return $this->updatedAt;
return $this->deleted;
}
public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
public function setDeleted(?bool $deleted): static
{
$this->updatedAt = $updatedAt;
$this->deleted = $deleted;
return $this;
}
#[ORM\PrePersist]
#[ORM\PreUpdate]
public function updateTimestamps(): void
{
$this->setUpdatedAt(new \DateTimeImmutable('now'));
}
}

View File

@@ -244,6 +244,11 @@ readonly class RDAPService
);
}
/** @var DomainEntity $domainEntity */
foreach ($domain->getDomainEntities()->getIterator() as $domainEntity) {
$domainEntity->setDeleted(true);
}
if (array_key_exists('entities', $res) && is_array($res['entities'])) {
foreach ($res['entities'] as $rdapEntity) {
if (!array_key_exists('handle', $rdapEntity) || '' === $rdapEntity['handle']) {
@@ -282,8 +287,9 @@ readonly class RDAPService
$domain->addDomainEntity($domainEntity
->setDomain($domain)
->setEntity($entity)
->setRoles($roles))
->updateTimestamps();
->setRoles($roles)
->setDeleted(false)
);
$this->em->persist($domainEntity);
$this->em->flush();