ogcore/src/Dto/Output/PartitionOutput.php

51 lines
1.6 KiB
PHP

<?php
namespace App\Dto\Output;
use ApiPlatform\Metadata\Get;
use App\Entity\Partition;
use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'Partition')]
class PartitionOutput extends AbstractOutput
{
#[Groups(['partition:read', 'client:read'])]
public ?int $diskNumber = null;
#[Groups(['partition:read', 'client:read'])]
public ?int $partitionNumber = null;
#[Groups(['partition:read', 'client:read'])]
public ?string $partitionCode = null;
#[Groups(['partition:read', 'client:read'])]
public ?int $size = null;
#[Groups(['partition:read', 'client:read'])]
public ?string $cacheContent = null;
#[Groups(['partition:read', 'client:read'])]
public ?string $filesystem = null;
#[Groups(['partition:read', 'client:read'])]
public ?OperativeSystemOutput $operativeSystem = null;
#[Groups(['partition:read', 'client:read'])]
public ?int $memoryUsage = null;
public function __construct(Partition $partition)
{
parent::__construct($partition);
$this->diskNumber = $partition->getDiskNumber();
$this->partitionNumber = $partition->getPartitionNumber();
$this->partitionCode = $partition->getPartitionCode();
$this->size = $partition->getSize() / 1024 ;
$this->cacheContent = $partition->getCacheContent();
$this->filesystem = $partition->getFilesystem();
if ($partition->getOperativeSystem()) {
$this->operativeSystem = new OperativeSystemOutput($partition->getOperativeSystem());
}
$this->memoryUsage = $partition->getMemoryUsage() / 100;
}
}