ogcore/src/Dto/Output/HardwareOutput.php

39 lines
1.0 KiB
PHP

<?php
namespace App\Dto\Output;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use App\Entity\Hardware;
use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'Hardware')]
final class HardwareOutput extends AbstractOutput
{
#[Groups(['hardware:read', 'hardware-profile:read'])]
public string $name;
#[Groups(['hardware:read'])]
public ?string $description = '';
#[Groups(['hardware:read'])]
#[ApiProperty(readableLink: true)]
public ?HardwareTypeOutput $type = null;
#[Groups(['hardware:read'])]
public \DateTime $createdAt;
#[Groups(['hardware:read'])]
public ?string $createdBy = null;
public function __construct(Hardware $hardware)
{
parent::__construct($hardware);
$this->name = $hardware->getName();
$this->description = $hardware->getDescription();
$this->type = new HardwareTypeOutput($hardware->getType());
$this->createdAt = $hardware->getCreatedAt();
$this->createdBy = $hardware->getCreatedBy();
}
}