- Domain-Entity polymorph (Reseller ODER Firma) - TenantResolver: Host → Plattform / reseller.portal / firma.reseller.portal / verifizierte Custom-Domain - Öffentliches GET /api/branding (Name, Ebene, Farben, Logo) nach Host - TLS-Gate nutzt TenantResolver (nur bekannte Hosts → Zertifikat) - Frontend: Branding-Store lädt vor Mount, färbt Theme um, TenantBrand- Komponente (Logo/Name je Tenant), Login zeigt Tenant - Vite-Proxy reicht Original-Host durch (lokales White-Label-Testing) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
156 lines
3.6 KiB
PHP
156 lines
3.6 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use App\Repository\DomainRepository;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Bridge\Doctrine\Types\UuidType;
|
|
use Symfony\Component\Uid\Uuid;
|
|
|
|
/**
|
|
* Sub- oder Custom-Domain eines Tenants (siehe KONZEPT §11).
|
|
* Gehört zu genau EINEM Reseller ODER einer Firma (Firmen-Domain ist via
|
|
* company.reseller implizit auch reseller-zugeordnet).
|
|
*/
|
|
#[ORM\Entity(repositoryClass: DomainRepository::class)]
|
|
#[ApiResource(security: "is_granted('ROLE_RESELLER_ADMIN')")]
|
|
class Domain implements ResellerOwnedInterface
|
|
{
|
|
public const TYPE_SUBDOMAIN = 'subdomain';
|
|
public const TYPE_CUSTOM = 'custom';
|
|
|
|
public const STATUS_PENDING = 'pending';
|
|
public const STATUS_VERIFIED = 'verified';
|
|
public const STATUS_FAILED = 'failed';
|
|
|
|
#[ORM\Id]
|
|
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
|
private Uuid $id;
|
|
|
|
#[ORM\Column(length: 255, unique: true)]
|
|
private string $hostname;
|
|
|
|
#[ORM\Column(length: 20)]
|
|
private string $type = self::TYPE_SUBDOMAIN;
|
|
|
|
#[ORM\Column(length: 20)]
|
|
private string $status = self::STATUS_PENDING;
|
|
|
|
#[ORM\Column(length: 20)]
|
|
private string $tlsStatus = 'none';
|
|
|
|
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
|
|
private ?\DateTimeImmutable $verificationCheckedAt = null;
|
|
|
|
/** Firmen-Domain (genau eines von company/reseller ist gesetzt). */
|
|
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'domains')]
|
|
#[ORM\JoinColumn(nullable: true)]
|
|
private ?Company $company = null;
|
|
|
|
/** Reseller-Domain (für reseller-eigene Subdomain/Custom-Domain). */
|
|
#[ORM\ManyToOne(targetEntity: Reseller::class)]
|
|
#[ORM\JoinColumn(nullable: true)]
|
|
private ?Reseller $reseller = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->id = Uuid::v7();
|
|
}
|
|
|
|
public function getId(): Uuid
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getHostname(): string
|
|
{
|
|
return $this->hostname;
|
|
}
|
|
|
|
public function setHostname(string $hostname): self
|
|
{
|
|
$this->hostname = $hostname;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getType(): string
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
public function setType(string $type): self
|
|
{
|
|
$this->type = $type;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus(): string
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setStatus(string $status): self
|
|
{
|
|
$this->status = $status;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTlsStatus(): string
|
|
{
|
|
return $this->tlsStatus;
|
|
}
|
|
|
|
public function setTlsStatus(string $tlsStatus): self
|
|
{
|
|
$this->tlsStatus = $tlsStatus;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getVerificationCheckedAt(): ?\DateTimeImmutable
|
|
{
|
|
return $this->verificationCheckedAt;
|
|
}
|
|
|
|
public function setVerificationCheckedAt(?\DateTimeImmutable $verificationCheckedAt): self
|
|
{
|
|
$this->verificationCheckedAt = $verificationCheckedAt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCompany(): ?Company
|
|
{
|
|
return $this->company;
|
|
}
|
|
|
|
public function setCompany(?Company $company): self
|
|
{
|
|
$this->company = $company;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getReseller(): ?Reseller
|
|
{
|
|
return $this->company?->getReseller() ?? $this->reseller;
|
|
}
|
|
|
|
public function setReseller(?Reseller $reseller): self
|
|
{
|
|
$this->reseller = $reseller;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/** Ebene der Domain: 'company' oder 'reseller'. */
|
|
public function getScope(): string
|
|
{
|
|
return null !== $this->company ? 'company' : 'reseller';
|
|
}
|
|
}
|