refs #725. Added RemoteCalendar into OrganizationalUnit

feature/calendars
Manuel Aranda Rosales 2024-09-30 11:45:25 +02:00
parent f6649231b6
commit d75712428d
3 changed files with 30 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace App\Dto\Input;
use ApiPlatform\Metadata\ApiProperty;
use App\Dto\Output\OrganizationalUnitOutput;
use App\Dto\Output\RemoteCalendarOutput;
use App\Entity\OrganizationalUnit;
use App\Validator\Constraints\OrganizationalUnitMulticastMode;
use App\Validator\Constraints\OrganizationalUnitMulticastPort;
@ -50,6 +51,9 @@ class OrganizationalUnitInput
#[Assert\Valid()]
public ?NetworkSettingsInput $networkSettings = null;
#[Groups(['organizational-unit:write'])]
public ?RemoteCalendarOutput $remoteCalendar = null;
public function __construct(?OrganizationalUnit $organizationalUnit = null)
{
if (!$organizationalUnit) {
@ -70,6 +74,10 @@ class OrganizationalUnitInput
if ($organizationalUnit->getNetworkSettings()){
$this->networkSettings = new NetworkSettingsInput($organizationalUnit->getNetworkSettings());
}
if ($organizationalUnit->getRemoteCalendar()) {
$this->remoteCalendar = new RemoteCalendarOutput($organizationalUnit->getRemoteCalendar());
}
}
public function createOrUpdateEntity(?OrganizationalUnit $organizationalUnit = null): OrganizationalUnit
@ -94,6 +102,10 @@ class OrganizationalUnitInput
$organizationalUnit->setNetworkSettings($this->networkSettings->createOrUpdateEntity($organizationalUnit->getNetworkSettings()));
}
if ($this->remoteCalendar) {
$organizationalUnit->setRemoteCalendar($this->remoteCalendar->getEntity());
}
return $organizationalUnit;
}
}

View File

@ -51,6 +51,10 @@ final class OrganizationalUnitOutput extends AbstractOutput
#[Groups(['organizational-unit:read'])]
public array $clients = [];
#[Groups(['organizational-unit:read', "client:read"])]
#[ApiProperty(readableLink: true)]
public ?RemoteCalendarOutput $remoteCalendar = null;
#[Groups(['organizational-unit:read'])]
public \DateTime $createdAt;
@ -70,7 +74,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
$this->capacity = $organizationalUnit->getCapacity();
$this->type = $organizationalUnit->getType();
$this->networkSettings = $organizationalUnit->getNetworkSettings() ? new NetworkSettingsOutput($organizationalUnit->getNetworkSettings()) : null;
$this->remoteCalendar = $organizationalUnit->getRemoteCalendar() ? new RemoteCalendarOutput($organizationalUnit->getRemoteCalendar()) : null;
if ($organizationalUnit->getParent()) {
$this->parent = new self($organizationalUnit->getParent());
}
@ -87,6 +91,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
)->toArray();
}
$this->path = $organizationalUnit->getPath();
$this->createdAt = $organizationalUnit->getCreatedAt();
$this->createdBy = $organizationalUnit->getCreatedBy();

View File

@ -372,4 +372,16 @@ class OrganizationalUnit extends AbstractEntity
return $this;
}
public function getRemoteCalendar(): ?RemoteCalendar
{
return $this->remoteCalendar;
}
public function setRemoteCalendar(?RemoteCalendar $remoteCalendar): static
{
$this->remoteCalendar = $remoteCalendar;
return $this;
}
}