ogcore/src/Dto/Output/CommandTaskOutput.php

61 lines
1.7 KiB
PHP

<?php
namespace App\Dto\Output;
use ApiPlatform\Metadata\Get;
use App\Entity\Client;
use App\Entity\Command;
use App\Entity\CommandGroup;
use App\Entity\CommandTask;
use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'CommandTask')]
final class CommandTaskOutput extends AbstractOutput
{
#[Groups(['command-task:read'])]
public ?string $name = null;
#[Groups(['command-task:read'])]
public array $clients = [];
#[Groups(['command-task:read'])]
public ?OrganizationalUnitOutput $organizationalUnit = null;
#[Groups(['command-task:read'])]
public ?\DateTimeInterface $lastExecution = null;
#[Groups(['command-task:read'])]
public ?\DateTimeInterface $nextExecution = null;
#[Groups(['command-task:read'])]
public ?string $notes = null;
#[Groups(['command-task:read'])]
public ?string $scope = null;
#[Groups(['command-task:read'])]
public \DateTime $createdAt;
#[Groups(['command-task:read'])]
public ?string $createdBy = null;
public function __construct(CommandTask $commandTask)
{
parent::__construct($commandTask);
$this->name = $commandTask->getName();
$this->clients = $commandTask->getClients()->map(
fn(Client $client) => new ClientOutput($client)
)->toArray();
$this->organizationalUnit = new OrganizationalUnitOutput($commandTask->getOrganizationalUnit());
$this->notes = $commandTask->getNotes();
$this->scope = $commandTask->getScope();
$this->lastExecution = $commandTask->getLastExecution();
$this->nextExecution = $commandTask->getNextExecution();
$this->createdAt = $commandTask->getCreatedAt();
$this->createdBy = $commandTask->getCreatedBy();
}
}