refs #1089. Partition assistant. Partition cpt=0
testing/ogcore-api/pipeline/head This commit looks good
Details
testing/ogcore-api/pipeline/head This commit looks good
Details
parent
2b8ea31599
commit
46999dfbc7
|
@ -6,13 +6,15 @@ use App\Entity\Client;
|
||||||
use App\Entity\OperativeSystem;
|
use App\Entity\OperativeSystem;
|
||||||
use App\Entity\Partition;
|
use App\Entity\Partition;
|
||||||
use App\Model\PartitionTypes;
|
use App\Model\PartitionTypes;
|
||||||
|
use App\Service\Utils\GetPartitionCodeService;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class CreatePartitionService
|
class CreatePartitionService
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected EntityManagerInterface $entityManager
|
protected EntityManagerInterface $entityManager,
|
||||||
|
protected GetPartitionCodeService $partitionCodeService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -54,11 +56,15 @@ class CreatePartitionService
|
||||||
$partitionEntity->setSize($cfg['tam']);
|
$partitionEntity->setSize($cfg['tam']);
|
||||||
|
|
||||||
if (isset($cfg['cpt']) && $cfg['cpt'] !== '') {
|
if (isset($cfg['cpt']) && $cfg['cpt'] !== '') {
|
||||||
|
if ($cfg['par'] === "0") {
|
||||||
|
$partitionType = $this->partitionCodeService->__invoke($cfg['cpt']);
|
||||||
|
} else {
|
||||||
$decimalValue = hexdec($cfg['cpt']);
|
$decimalValue = hexdec($cfg['cpt']);
|
||||||
$partitionType = PartitionTypes::getPartitionType($decimalValue);
|
$partitionType = PartitionTypes::getPartitionType($decimalValue);
|
||||||
|
}
|
||||||
|
|
||||||
if ($partitionType) {
|
if ($partitionType) {
|
||||||
$partitionEntity->setPartitionCode($partitionType['name']);
|
$partitionEntity->setPartitionCode($partitionType['name'] ?? $partitionType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$partitionEntity->setPartitionCode(PartitionTypes::getPartitionType(0)['name']);
|
$partitionEntity->setPartitionCode(PartitionTypes::getPartitionType(0)['name']);
|
||||||
|
|
|
@ -2,7 +2,16 @@
|
||||||
|
|
||||||
namespace App\Service\Utils;
|
namespace App\Service\Utils;
|
||||||
|
|
||||||
class GetPartitionCode
|
class GetPartitionCodeService
|
||||||
{
|
{
|
||||||
|
public function __invoke(string $partitionCode): string
|
||||||
|
{
|
||||||
|
return match ($partitionCode) {
|
||||||
|
"1" => "MSDOS",
|
||||||
|
"2" => "GPT",
|
||||||
|
"3" => "LVM",
|
||||||
|
"4" => "ZPOOL",
|
||||||
|
default => "UNKNOWN",
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue