refs #421. Some improvements in DTO output
parent
5d1b553c0b
commit
74fac8d0af
|
@ -3,9 +3,9 @@ resources:
|
|||
processor: App\State\Processor\ClientProcessor
|
||||
input: App\Dto\Input\ClientInput
|
||||
output: App\Dto\Output\ClientOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'client:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['client:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -3,9 +3,9 @@ resources:
|
|||
processor: App\State\Processor\HardwareProcessor
|
||||
input: App\Dto\Input\HardwareInput
|
||||
output: App\Dto\Output\HardwareOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'hardware:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['hardware:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -3,9 +3,9 @@ resources:
|
|||
processor: App\State\Processor\HardwareProfileProcessor
|
||||
input: App\Dto\Input\HardwareProfileInput
|
||||
output: App\Dto\Output\HardwareProfileOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'hardware-profile:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['hardware-profile:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -3,9 +3,9 @@ resources:
|
|||
processor: App\State\Processor\HardwareTypeProcessor
|
||||
input: App\Dto\Input\HardwareTypeInput
|
||||
output: App\Dto\Output\HardwareTypeOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'hardware-type:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['hardware-type:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -3,9 +3,9 @@ resources:
|
|||
processor: App\State\Processor\MenuProcessor
|
||||
input: App\Dto\Input\MenuInput
|
||||
output: App\Dto\Output\MenuOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'menu:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['menu:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -3,9 +3,9 @@ resources:
|
|||
processor: App\State\Processor\OperativeSystemProcessor
|
||||
input: App\Dto\Input\OperativeSystemInput
|
||||
output: App\Dto\Output\OperativeSystemOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'operative-system:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['operative-system:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -3,7 +3,7 @@ resources:
|
|||
processor: App\State\Processor\OrganizationalUnitProcessor
|
||||
output: App\Dto\Output\OrganizationalUnitOutput
|
||||
input: App\Dto\Input\OrganizationalUnitInput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'organizational-unit:read']
|
||||
denormalization_context:
|
||||
groups: ['organizational-unit:write']
|
||||
|
|
|
@ -3,9 +3,9 @@ resources:
|
|||
processor: App\State\Processor\PartitionProcessor
|
||||
input: App\Dto\Input\PartitionInput
|
||||
output: App\Dto\Output\PartitionOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'partition:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['partition:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -3,9 +3,9 @@ resources:
|
|||
input: App\Dto\Input\UserInput
|
||||
output: App\Dto\Output\UserOutput
|
||||
processor: App\State\Processor\UserProcessor
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'user:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['user:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -4,9 +4,9 @@ resources:
|
|||
processor: App\State\Processor\UserGroupProcessor
|
||||
input: App\Dto\Input\UserGroupInput
|
||||
output: App\Dto\Output\UserGroupOutput
|
||||
normalization_context:
|
||||
normalizationContext:
|
||||
groups: ['default', 'user-group:read']
|
||||
denormalization_context:
|
||||
denormalizationContext:
|
||||
groups: ['user-group:write']
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
class HardwareTypeInput
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Groups(['hardware-type:read'])]
|
||||
#[Groups(['hardware-type:write'])]
|
||||
public ?string $name = null;
|
||||
|
||||
public function __construct(?HardwareType $hardwareType = null)
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
class OperativeSystemInput
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Groups(['operative-system:read'])]
|
||||
#[Groups(['operative-system:write'])]
|
||||
public ?string $name = null;
|
||||
|
||||
public function __construct(?OperativeSystem $operativeSystem = null)
|
||||
|
|
|
@ -21,6 +21,7 @@ final class ClientOutput extends AbstractOutput
|
|||
public ?string $netiface = '';
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
#[ApiProperty(readableLink: true )]
|
||||
public ?OrganizationalUnitOutput $organizationalUnit = null;
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
|
@ -30,6 +31,7 @@ final class ClientOutput extends AbstractOutput
|
|||
public ?MenuOutput $menu = null;
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
#[ApiProperty(readableLink: true )]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['client:read'])]
|
||||
|
|
|
@ -10,7 +10,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
#[Get(shortName: 'Hardware')]
|
||||
final class HardwareOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['hardware:read'])]
|
||||
#[Groups(['hardware:read', 'hardware-profile:read'])]
|
||||
public string $name;
|
||||
|
||||
#[Groups(['hardware:read'])]
|
||||
|
|
|
@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
#[Get(shortName: 'HardwareProfile')]
|
||||
final class HardwareProfileOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['hardware-profile:read'])]
|
||||
#[Groups(['hardware-profile:read', 'client:read'])]
|
||||
public ?string $description = '';
|
||||
|
||||
#[Groups(['hardware-profile:read'])]
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
#[Get(shortName: 'HardwareType')]
|
||||
final class HardwareTypeOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['hardware-type:read'])]
|
||||
#[Groups(['hardware-type:read', 'hardware:read'])]
|
||||
public string $name;
|
||||
|
||||
public function __construct(HardwareType $hardwareType)
|
||||
|
|
|
@ -9,46 +9,46 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
#[Get(shortName: 'NetworkSettings')]
|
||||
final class NetworkSettingsOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['network-settings:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $proxy = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $dns = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $netmask = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $router = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $ntp = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $p2pMode = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?int $p2pTime = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $mcastIp = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?int $mcastSpeed = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?int $mcastPort = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?string $mcastMode = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?MenuOutput $menu = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
public ?HardwareProfileOutput $hardwareProfile = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
|
||||
public ?bool $validation = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
|
|
|
@ -9,7 +9,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
|||
#[Get(shortName: 'OperativeSystem')]
|
||||
final class OperativeSystemOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['operative-system:read'])]
|
||||
#[Groups(['operative-system:read', 'partition:read'])]
|
||||
public string $name;
|
||||
|
||||
public function __construct(OperativeSystem $operativeSystem)
|
||||
|
|
|
@ -4,14 +4,13 @@ namespace App\Dto\Output;
|
|||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\ClientProperties;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
#[Get(shortName: 'OrganizationalUnit')]
|
||||
final class OrganizationalUnitOutput extends AbstractOutput
|
||||
{
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['organizational-unit:read', "client:read", "user:read"])]
|
||||
public string $name;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
|
@ -29,7 +28,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
|
|||
#[Groups(['organizational-unit:read'])]
|
||||
public ?int $capacity = null;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['organizational-unit:read', "client:read"])]
|
||||
public string $type;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
|
@ -38,7 +37,7 @@ final class OrganizationalUnitOutput extends AbstractOutput
|
|||
#[Groups(['organizational-unit:read'])]
|
||||
public string $path;
|
||||
|
||||
#[Groups(['organizational-unit:read'])]
|
||||
#[Groups(['organizational-unit:read', "client:read"])]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
public ?NetworkSettingsOutput $networkSettings = null;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Dto\Output;
|
||||
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use App\Entity\OrganizationalUnit;
|
||||
use App\Entity\User;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
|
@ -36,7 +37,11 @@ final class UserOutput extends AbstractOutput
|
|||
$this->roles = $user->getRoles();
|
||||
$this->enabled = $user->isEnabled();
|
||||
$this->userGroups = $user->getUserGroups()->toArray();
|
||||
$this->allowedOrganizationalUnits = $user->getAllowedOrganizationalUnits()->toArray();
|
||||
|
||||
$this->allowedOrganizationalUnits = $user->getAllowedOrganizationalUnits()->map(
|
||||
fn(OrganizationalUnit $organizationalUnit) => new OrganizationalUnitOutput($organizationalUnit)
|
||||
)->toArray();
|
||||
|
||||
$this->createAt = $user->getCreatedAt();
|
||||
$this->createBy = $user->getCreatedBy();
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ class HardwareTypeProvider implements ProviderInterface
|
|||
$item = $this->itemProvider->provide($operation, $uriVariables, $context);
|
||||
|
||||
if (!$item) {
|
||||
throw new NotFoundHttpException('Operative system not found');
|
||||
throw new NotFoundHttpException('hardware type not found');
|
||||
}
|
||||
|
||||
return new HardwareTypeOutput($item);
|
||||
|
|
|
@ -91,7 +91,6 @@ class PartitionTest extends AbstractTest
|
|||
'@context' => '/contexts/PartitionOutput',
|
||||
'@type' => 'Partition',
|
||||
'size' => 100,
|
||||
'operativeSystem' => $osIri,
|
||||
'memoryUsage' => 100
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue