mirror of
https://github.com/Karaka-Management/oms-AssetManagement.git
synced 2026-01-11 22:58:40 +00:00
code fixes
This commit is contained in:
parent
c3696f44db
commit
2d71cfd132
|
|
@ -132,67 +132,6 @@ final class Installer extends InstallerAbstract
|
|||
return $assetTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install inspection type
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $types Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createInspectionTypes(ApplicationAbstract $app, array $types) : array
|
||||
{
|
||||
/** @var array<string, array> $inspectionTypes */
|
||||
$inspectionTypes = [];
|
||||
|
||||
/** @var \Modules\AssetManagement\Controller\ApiInspectionTypeController $module */
|
||||
$module = $app->moduleManager->get('AssetManagement', 'ApiInspectionType');
|
||||
|
||||
/** @var array $type */
|
||||
foreach ($types as $type) {
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest();
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('name', $type['name'] ?? '');
|
||||
$request->setData('title', \reset($type['l11n']));
|
||||
$request->setData('language', \array_keys($type['l11n'])[0] ?? 'en');
|
||||
|
||||
$module->apiInspectionTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->getData('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$inspectionTypes[$type['name']] = \is_array($responseData['response'])
|
||||
? $responseData['response']
|
||||
: $responseData['response']->toArray();
|
||||
|
||||
$isFirst = true;
|
||||
foreach ($type['l11n'] as $language => $l11n) {
|
||||
if ($isFirst) {
|
||||
$isFirst = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest();
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n);
|
||||
$request->setData('language', $language);
|
||||
$request->setData('type', $inspectionTypes[$type['name']]['id']);
|
||||
|
||||
$module->apiInspectionTypeL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
|
||||
return $inspectionTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install default attribute types
|
||||
*
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
|||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of AssetType
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AssetTypeMapper extends DataMapperFactory
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user