137 lines
4.8 KiB
PHP
137 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace App\Dto\Input;
|
|
|
|
use App\Dto\Output\HardwareProfileOutput;
|
|
use App\Dto\Output\MenuOutput;
|
|
use App\Entity\HardwareProfile;
|
|
use App\Entity\Menu;
|
|
use App\Entity\NetworkSettings;
|
|
use App\Validator\Constraints\OrganizationalUnitMulticastMode;
|
|
use App\Validator\Constraints\OrganizationalUnitMulticastPort;
|
|
use App\Validator\Constraints\OrganizationalUnitP2PMode;
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
class NetworkSettingsInput
|
|
{
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $nextServer = null;
|
|
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $bootFileName = null;
|
|
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $proxy = null;
|
|
|
|
#[Assert\Ip(message: 'validators.network_settings.ip_address.invalid')]
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $dns = null;
|
|
|
|
#[Assert\Ip(message: 'validators.network_settings.ip_address.invalid')]
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $netmask = null;
|
|
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $router = null;
|
|
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $ntp = null;
|
|
|
|
#[OrganizationalUnitP2PMode]
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $p2pMode = null;
|
|
|
|
#[Assert\GreaterThan(0, message: 'validators.network_settings.p2p_time.invalid')]
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?int $p2pTime = null;
|
|
|
|
#[Assert\Ip(message: 'validators.network_settings.ip_address.invalid')]
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $mcastIp = null;
|
|
|
|
#[Assert\GreaterThan(0, message: 'validators.network_settings.mcast_speed.invalid')]
|
|
#[Groups(['organizational-write:write'])]
|
|
public ?int $mcastSpeed = null;
|
|
|
|
#[OrganizationalUnitMulticastPort]
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?int $mcastPort = null;
|
|
|
|
#[OrganizationalUnitMulticastMode]
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?string $mcastMode = null;
|
|
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?MenuOutput $menu = null;
|
|
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?HardwareProfileOutput $hardwareProfile = null;
|
|
|
|
#[Groups(['organizational-unit:write'])]
|
|
public ?bool $validation = null;
|
|
|
|
public function __construct(?NetworkSettings $networkSettings = null)
|
|
{
|
|
if (!$networkSettings) {
|
|
return;
|
|
}
|
|
|
|
$this->nextServer = $networkSettings->getNextServer();
|
|
$this->bootFileName = $networkSettings->getBootFileName();
|
|
$this->proxy = $networkSettings->getProxy();
|
|
$this->dns = $networkSettings->getDns();
|
|
$this->netmask = $networkSettings->getNetmask();
|
|
$this->router = $networkSettings->getRouter();
|
|
$this->ntp = $networkSettings->getNtp();
|
|
$this->p2pMode = $networkSettings->getP2pMode();
|
|
$this->p2pTime = $networkSettings->getP2pTime();
|
|
$this->mcastIp = $networkSettings->getMcastIp();
|
|
$this->mcastSpeed = $networkSettings->getMcastSpeed();
|
|
$this->mcastPort = $networkSettings->getMcastPort();
|
|
$this->mcastMode = $networkSettings->getMcastMode();
|
|
|
|
if ($networkSettings->getMenu()) {
|
|
$this->menu = new MenuOutput($networkSettings->getMenu());
|
|
}
|
|
|
|
if ($networkSettings->getHardwareProfile()) {
|
|
$this->hardwareProfile = new HardwareProfileOutput($networkSettings->getHardwareProfile());
|
|
}
|
|
|
|
$this->validation = $networkSettings->getValidation();
|
|
}
|
|
|
|
public function createOrUpdateEntity(?NetworkSettings $networkSettings = null): NetworkSettings
|
|
{
|
|
if (!$networkSettings) {
|
|
$networkSettings = new NetworkSettings();
|
|
}
|
|
|
|
$networkSettings->setNextServer($this->nextServer);
|
|
$networkSettings->setBootFileName($this->bootFileName);
|
|
$networkSettings->setProxy($this->proxy);
|
|
$networkSettings->setDns($this->dns);
|
|
$networkSettings->setNetmask($this->netmask);
|
|
$networkSettings->setRouter($this->router);
|
|
$networkSettings->setNtp($this->ntp);
|
|
$networkSettings->setP2pMode($this->p2pMode);
|
|
$networkSettings->setP2pTime($this->p2pTime);
|
|
$networkSettings->setMcastIp($this->mcastIp);
|
|
$networkSettings->setMcastSpeed($this->mcastSpeed);
|
|
$networkSettings->setMcastPort($this->mcastPort);
|
|
$networkSettings->setMcastMode($this->mcastMode);
|
|
|
|
if ($this->menu) {
|
|
$networkSettings->setMenu($this->menu->getEntity());
|
|
}
|
|
|
|
if ($this->hardwareProfile) {
|
|
$networkSettings->setHardwareProfile($this->hardwareProfile->getEntity());
|
|
}
|
|
|
|
$networkSettings->setValidation($this->validation);
|
|
|
|
return $networkSettings;
|
|
}
|
|
} |