44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Dto\Input;
|
|
|
|
use ApiPlatform\Metadata\ApiProperty;
|
|
use App\Entity\OgLive;
|
|
use App\Model\OgLiveStatus;
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
final class OgLiveInput
|
|
{
|
|
#[Assert\NotBlank(message: 'validators.hardware.name.not_blank')]
|
|
#[Groups(['og-live:write'])]
|
|
#[ApiProperty(description: 'The name of the ogLive', example: "OgLive 1")]
|
|
public ?string $name = null;
|
|
|
|
#[Groups(['og-live:write'])]
|
|
#[ApiProperty(description: 'The download url of the ogLive', example: "http://example.com/oglive1.iso")]
|
|
public ?string $downloadUrl = null;
|
|
|
|
public function __construct(?OgLive $ogLive = null)
|
|
{
|
|
if (!$ogLive) {
|
|
return;
|
|
}
|
|
|
|
$this->name = $ogLive->getName();
|
|
$this->downloadUrl = $ogLive->getDownloadUrl();
|
|
}
|
|
|
|
public function createOrUpdateEntity(?OgLive $ogLive = null): OgLive
|
|
{
|
|
if (!$ogLive) {
|
|
$ogLive = new OgLive();
|
|
}
|
|
|
|
$ogLive->setName($this->name);
|
|
$ogLive->setDownloadUrl($this->downloadUrl);
|
|
$ogLive->setStatus(OgLiveStatus::INACTIVE);
|
|
|
|
return $ogLive;
|
|
}
|
|
} |