37 lines
1019 B
PHP
37 lines
1019 B
PHP
<?php
|
|
|
|
namespace App\Dto\Output;
|
|
|
|
use ApiPlatform\Metadata\Get;
|
|
use App\Entity\RemoteCalendar;
|
|
use App\Entity\RemoteCalendarRule;
|
|
use Symfony\Component\Serializer\Annotation\Groups;
|
|
|
|
#[Get(shortName: 'RemoteCalendar')]
|
|
final class RemoteCalendarOutput extends AbstractOutput
|
|
{
|
|
#[Groups(['remote-calendar:read', 'organizational-unit:read'])]
|
|
public ?string $name = null;
|
|
|
|
/**
|
|
* @var RemoteCalendarRuleOutput[]
|
|
*/
|
|
#[Groups(['remote-calendar:read'])]
|
|
public array $remoteCalendarRules = [];
|
|
|
|
#[Groups(['remote-calendar:read'])]
|
|
public ?\DateTimeInterface $createdAt = null;
|
|
|
|
public function __construct(RemoteCalendar $remoteCalendar)
|
|
{
|
|
parent::__construct($remoteCalendar);
|
|
|
|
$this->name = $remoteCalendar->getName();
|
|
|
|
$this->remoteCalendarRules = $remoteCalendar->getRules()->map(
|
|
fn(RemoteCalendarRule $rule) => new RemoteCalendarRuleOutput($rule)
|
|
)->toArray();
|
|
|
|
$this->createdAt = $remoteCalendar->getCreatedAt();
|
|
}
|
|
} |