ogcore/src/Dto/Output/PxeTemplateOutput.php

47 lines
1.3 KiB
PHP

<?php
namespace App\Dto\Output;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use App\Entity\Client;
use App\Entity\PxeTemplate;
use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'PxeTemplate')]
final class PxeTemplateOutput extends AbstractOutput
{
#[Groups(['pxe-template:read', 'client:read', 'organizational-unit:read'])]
public string $name;
#[Groups(['pxe-template:read'])]
public ?bool $synchronized = null;
#[Groups(['pxe-template:read'])]
public ?string $templateContent = '';
#[Groups(['pxe-template:read'])]
public ?bool $isDefault = null;
#[Groups(['pxe-template:read'])]
public ?int $clientsLength = 0;
#[Groups(['pxe-template:read'])]
public \DateTime $createdAt;
#[Groups(['pxe-template:read'])]
public ?string $createdBy = null;
public function __construct(PxeTemplate $pxeTemplate)
{
parent::__construct($pxeTemplate);
$this->name = $pxeTemplate->getName();
$this->synchronized = $pxeTemplate->isSynchronized();
$this->templateContent = $pxeTemplate->getTemplateContent();
$this->clientsLength = $pxeTemplate->getClients()->count();
$this->isDefault = $pxeTemplate->isDefault();
$this->createdAt = $pxeTemplate->getCreatedAt();
$this->createdBy = $pxeTemplate->getCreatedBy();
}
}