ogcore/src/Dto/Output/ImageOutput.php

69 lines
1.9 KiB
PHP

<?php
namespace App\Dto\Output;
use ApiPlatform\Metadata\Get;
use App\Entity\Image;
use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'Image')]
final class ImageOutput extends AbstractOutput
{
#[Groups(['image:read'])]
public ?string $name = '';
#[Groups(['image:read'])]
public ?string $description = '';
#[Groups(['image:read'])]
public ?string $comments = '';
#[Groups(['image:read'])]
public ?string $type = null;
#[Groups(['image:read'])]
public ?string $path = '';
#[Groups(['image:read'])]
public ?string $revision = '';
#[Groups(['image:read'])]
public ?string $info = '';
#[Groups(['image:read'])]
public ?int $size = null;
#[Groups(['image:read'])]
public ?bool $remotePc = null;
#[Groups(['image:read'])]
public ?SoftwareProfileOutput $softwareProfile = null;
#[Groups(['image:read'])]
public ?ImageRepositoryOutput $imageRepository = null;
#[Groups(['image:read'])]
public \DateTime $createdAt;
#[Groups(['image:read'])]
public ?string $createdBy = null;
public function __construct(Image $image)
{
parent::__construct($image);
$this->name = $image->getName();
$this->description = $image->getDescription();
$this->comments = $image->getComments();
$this->type = $image->getType();
$this->path = $image->getPath();
$this->revision = $image->getRevision();
$this->info = $image->getInfo();
$this->size = $image->getSize();
$this->softwareProfile = $image->getSoftwareProfile() ? new SoftwareProfileOutput($image->getSoftwareProfile()) : null;
$this->imageRepository = $image->getRepository() ? new ImageRepositoryOutput($image->getRepository()) : null;
$this->remotePc = $image->isRemotePc();
$this->createdAt = $image->getCreatedAt();
$this->createdBy = $image->getCreatedBy();
}
}