mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
97 lines
2.3 KiB
PHP
97 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Config\DomainRole;
|
|
use App\Repository\DomainEntityRepository;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Serializer\Attribute\Groups;
|
|
|
|
#[ORM\Entity(repositoryClass: DomainEntityRepository::class)]
|
|
class DomainEntity
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\ManyToOne(targetEntity: Domain::class, cascade: ['persist'], inversedBy: 'domainEntities')]
|
|
#[ORM\JoinColumn(referencedColumnName: 'ldh_name', nullable: false)]
|
|
#[Groups('domain-entity:domain')]
|
|
private ?Domain $domain = null;
|
|
|
|
#[ORM\Id]
|
|
#[ORM\ManyToOne(targetEntity: Entity::class, cascade: ['persist'], inversedBy: 'domainEntities')]
|
|
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
|
|
#[Groups(['domain-entity:entity'])]
|
|
private ?Entity $entity = null;
|
|
|
|
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
|
|
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
|
private array $roles = [];
|
|
|
|
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
|
|
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
|
|
private ?\DateTimeImmutable $updatedAt = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->updatedAt = new \DateTimeImmutable('now');
|
|
}
|
|
|
|
public function getDomain(): ?Domain
|
|
{
|
|
return $this->domain;
|
|
}
|
|
|
|
public function setDomain(?Domain $domain): static
|
|
{
|
|
$this->domain = $domain;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEntity(): ?Entity
|
|
{
|
|
return $this->entity;
|
|
}
|
|
|
|
public function setEntity(?Entity $entity): static
|
|
{
|
|
$this->entity = $entity;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return DomainRole[]
|
|
*/
|
|
public function getRoles(): array
|
|
{
|
|
return $this->roles;
|
|
}
|
|
|
|
public function setRoles(array $roles): static
|
|
{
|
|
$this->roles = $roles;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getUpdatedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->updatedAt;
|
|
}
|
|
|
|
public function setUpdatedAt(\DateTimeImmutable $updatedAt): static
|
|
{
|
|
$this->updatedAt = $updatedAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
#[ORM\PrePersist]
|
|
#[ORM\PreUpdate]
|
|
public function updateTimestamps(): void
|
|
{
|
|
$this->setUpdatedAt(new \DateTimeImmutable('now'));
|
|
}
|
|
}
|