Files
domain-watchdog/src/Entity/DomainEntity.php

97 lines
2.3 KiB
PHP
Raw Normal View History

2024-07-10 23:30:59 +02:00
<?php
namespace App\Entity;
2024-07-11 13:15:04 +02:00
use App\Config\DomainRole;
2024-07-10 23:30:59 +02:00
use App\Repository\DomainEntityRepository;
2024-07-11 00:29:37 +02:00
use Doctrine\DBAL\Types\Types;
2024-07-10 23:30:59 +02:00
use Doctrine\ORM\Mapping as ORM;
2024-07-17 00:19:27 +02:00
use Symfony\Component\Serializer\Attribute\Groups;
2024-07-10 23:30:59 +02:00
#[ORM\Entity(repositoryClass: DomainEntityRepository::class)]
class DomainEntity
{
#[ORM\Id]
2024-07-12 00:50:30 +02:00
#[ORM\ManyToOne(targetEntity: Domain::class, cascade: ['persist'], inversedBy: 'domainEntities')]
2024-07-13 12:49:11 +02:00
#[ORM\JoinColumn(referencedColumnName: 'ldh_name', nullable: false)]
2024-07-17 00:19:27 +02:00
#[Groups('domain-entity:domain')]
2024-07-10 23:30:59 +02:00
private ?Domain $domain = null;
2024-07-10 23:58:59 +02:00
#[ORM\Id]
2024-07-12 00:50:30 +02:00
#[ORM\ManyToOne(targetEntity: Entity::class, cascade: ['persist'], inversedBy: 'domainEntities')]
2024-07-13 17:04:29 +02:00
#[ORM\JoinColumn(referencedColumnName: 'handle', nullable: false)]
2024-07-17 00:19:27 +02:00
#[Groups(['domain-entity:entity'])]
2024-07-10 23:30:59 +02:00
private ?Entity $entity = null;
2024-07-23 03:05:35 +02:00
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
2024-07-17 00:19:27 +02:00
#[Groups(['domain-entity:entity', 'domain-entity:domain'])]
2024-07-11 00:29:37 +02:00
private array $roles = [];
2024-07-10 23:30:59 +02:00
2024-08-06 19:05:02 +02:00
#[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');
}
2024-07-10 23:30:59 +02:00
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;
}
2024-07-11 13:15:04 +02:00
/**
* @return DomainRole[]
*/
public function getRoles(): array
2024-07-10 23:30:59 +02:00
{
return $this->roles;
}
2024-07-11 00:29:37 +02:00
public function setRoles(array $roles): static
2024-07-10 23:30:59 +02:00
{
$this->roles = $roles;
return $this;
}
2024-08-06 19:05:02 +02:00
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'));
}
2024-07-10 23:30:59 +02:00
}