refactor(inventory): optimize extraction of fwt and spd in CreatePartitionService
parent
809ecd0d37
commit
33609081bf
|
|
@ -30,20 +30,27 @@ class CreatePartitionService
|
|||
return isset($cfg['disk'], $cfg['par'], $cfg['tam'], $cfg['uso'], $cfg['fsi']);
|
||||
});
|
||||
|
||||
$fwtFound = false;
|
||||
$spdFound = false;
|
||||
|
||||
foreach ($data['cfg'] as $cfg) {
|
||||
if (!empty($cfg['fwt'])) {
|
||||
if (!$fwtFound && !empty($cfg['fwt'])) {
|
||||
$clientEntity->setFirmwareType($cfg['fwt']);
|
||||
$this->entityManager->persist($clientEntity);
|
||||
$fwtFound = true;
|
||||
}
|
||||
|
||||
if (!$spdFound && !empty($cfg['spd'])) {
|
||||
$clientEntity->setNetSpeed((int) $cfg['spd']);
|
||||
$spdFound = true;
|
||||
}
|
||||
|
||||
if ($fwtFound && $spdFound) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($data['cfg'] as $cfg) {
|
||||
if (!empty($cfg['spd'])) {
|
||||
$clientEntity->setNetSpeed((int) $cfg['spd']);
|
||||
$this->entityManager->persist($clientEntity);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($fwtFound || $spdFound) {
|
||||
$this->entityManager->persist($clientEntity);
|
||||
}
|
||||
|
||||
foreach ($filteredCfg as $cfg) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue