ogcore/src/Dto/Output/UserGroupOutput.php

38 lines
967 B
PHP

<?php
namespace App\Dto\Output;
use ApiPlatform\Metadata\Get;
use App\Entity\User;
use App\Entity\UserGroup;
use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'UserGroup')]
final class UserGroupOutput extends AbstractOutput
{
#[Groups(['user-group:read', 'user:read'])]
public string $name;
#[Groups(['user-group:read'])]
public array $permissions;
#[Groups(['user-group:read'])]
public bool $enabled;
#[Groups(['user-group:read'])]
public \DateTime $createdAt;
#[Groups(['user-group:read'])]
public ?string $createdBy = null;
public function __construct(UserGroup $userGroup)
{
parent::__construct($userGroup);
$this->name = $userGroup->getName();
$this->permissions = $userGroup->getPermissions();
$this->enabled = $userGroup->isEnabled();
$this->createdAt = $userGroup->getCreatedAt();
$this->createdBy = $userGroup->getCreatedBy();
}
}