ogcore/src/Dto/Input/HardwareProfileInput.php

40 lines
1.2 KiB
PHP

<?php
namespace App\Dto\Input;
use ApiPlatform\Metadata\ApiProperty;
use App\Entity\HardwareProfile;
use Symfony\Component\Serializer\Annotation\Groups;
final class HardwareProfileInput
{
#[Groups(['hardware-profile:write'])]
#[ApiProperty(description: 'The description of the hardware profile', example: "Hardware 1 description")]
public ?string $description = null;
#[Groups(['hardware-profile:write'])]
#[ApiProperty(description: 'Comments of the hardware profile', example: "Hardware 1")]
public ?string $comments = null;
public function __construct(?HardwareProfile $hardwareProfile = null)
{
if (!$hardwareProfile) {
return;
}
$this->description = $hardwareProfile->getDescription();
$this->comments = $hardwareProfile->getComments();
}
public function createOrUpdateEntity(?HardwareProfile $hardwareProfile = null): HardwareProfile
{
if (!$hardwareProfile) {
$hardwareProfile = new HardwareProfile();
}
$hardwareProfile->setDescription($this->description);
$hardwareProfile->setComments($this->comments);
return $hardwareProfile;
}
}