Lorsqu'un super-admin crée un établissement via l'interface, le système doit automatiquement créer la base tenant, exécuter les migrations, créer le premier utilisateur admin et envoyer l'invitation — le tout de manière asynchrone pour ne pas bloquer la réponse HTTP. Ce mécanisme rend chaque établissement opérationnel dès sa création sans intervention manuelle sur l'infrastructure.
38 lines
860 B
PHP
38 lines
860 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\SuperAdmin\Domain\Event;
|
|
|
|
use App\Shared\Domain\DomainEvent;
|
|
use App\Shared\Domain\Tenant\TenantId;
|
|
use App\SuperAdmin\Domain\Model\Establishment\EstablishmentId;
|
|
use DateTimeImmutable;
|
|
use Override;
|
|
use Ramsey\Uuid\UuidInterface;
|
|
|
|
final readonly class EtablissementCree implements DomainEvent
|
|
{
|
|
public function __construct(
|
|
public EstablishmentId $establishmentId,
|
|
public TenantId $tenantId,
|
|
public string $name,
|
|
public string $subdomain,
|
|
public string $adminEmail,
|
|
private DateTimeImmutable $occurredOn,
|
|
) {
|
|
}
|
|
|
|
#[Override]
|
|
public function occurredOn(): DateTimeImmutable
|
|
{
|
|
return $this->occurredOn;
|
|
}
|
|
|
|
#[Override]
|
|
public function aggregateId(): UuidInterface
|
|
{
|
|
return $this->establishmentId->value;
|
|
}
|
|
}
|