49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Dto\Output;
|
|
|
|
use ApiPlatform\Metadata\ApiProperty;
|
|
use ApiPlatform\Metadata\Get;
|
|
use App\Entity\Software;
|
|
use App\Entity\SoftwareProfile;
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
|
|
#[Get(shortName: 'SoftwareProfile')]
|
|
final class SoftwareProfileOutput extends AbstractOutput
|
|
{
|
|
#[Groups(['software-profile:read'])]
|
|
public ?string $description = '';
|
|
|
|
#[Groups(['software-profile:read'])]
|
|
public ?string $comments = '';
|
|
|
|
#[Groups(['software-profile:read'])]
|
|
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
|
|
|
#[Groups(['software-profile:read'])]
|
|
public ?array $softwareCollection = [];
|
|
|
|
#[Groups(['software-profile:read'])]
|
|
public \DateTime $createdAt;
|
|
|
|
#[Groups(['software-profile:read'])]
|
|
public ?string $createdBy = null;
|
|
|
|
public function __construct(SoftwareProfile $softwareProfile)
|
|
{
|
|
parent::__construct($softwareProfile);
|
|
|
|
$this->description = $softwareProfile->getDescription();
|
|
$this->comments = $softwareProfile->getComments();
|
|
if($softwareProfile->getOrganizationalUnit()) {
|
|
$this->organizationalUnit = new OrganizationalUnitOutput($softwareProfile->getOrganizationalUnit());
|
|
}
|
|
|
|
$this->softwareCollection = $softwareProfile->getSoftwareCollection()->map(
|
|
fn(Software $hardware) => new SoftwareOutput($hardware)
|
|
)->toArray();
|
|
|
|
$this->createdAt = $softwareProfile->getCreatedAt();
|
|
$this->createdBy = $softwareProfile->getCreatedBy();
|
|
}
|
|
} |