mirror of
https://github.com/Karaka-Management/oms-ItemManagement.git
synced 2026-01-25 10:08:41 +00:00
l11n, unit/app and simplification fixes
This commit is contained in:
parent
218497895b
commit
35af6cfe4d
|
|
@ -12,5 +12,19 @@
|
|||
"name": "Articles",
|
||||
"virtualPath": "/Modules/ItemManagement",
|
||||
"user": 1
|
||||
},
|
||||
{
|
||||
"type": "type",
|
||||
"name": "item_profile_image",
|
||||
"l11n": [
|
||||
{
|
||||
"title": "Profile image",
|
||||
"lang": "en"
|
||||
},
|
||||
{
|
||||
"title": "Profilbild",
|
||||
"lang": "de"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -1,11 +1,71 @@
|
|||
[
|
||||
{
|
||||
"name": "featured",
|
||||
"l11n": {
|
||||
"en": "Featured",
|
||||
"de": "Featured"
|
||||
},
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": [
|
||||
{
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "shop",
|
||||
"l11n": {
|
||||
"en": "Shop Item",
|
||||
"de": "Shop Artikel"
|
||||
},
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": [
|
||||
{
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "front",
|
||||
"l11n": {
|
||||
"en": "Frontpage",
|
||||
"de": "Frontpage"
|
||||
},
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": [
|
||||
{
|
||||
"value": 0
|
||||
},
|
||||
{
|
||||
"value": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "segment",
|
||||
"l11n": {
|
||||
"en": "Segment",
|
||||
"de": "Segment"
|
||||
},
|
||||
"value_type": "int",
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": true,
|
||||
|
|
@ -26,7 +86,7 @@
|
|||
"en": "Section",
|
||||
"de": "Sparte"
|
||||
},
|
||||
"value_type": "int",
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": true,
|
||||
|
|
@ -47,7 +107,7 @@
|
|||
"en": "Product Group",
|
||||
"de": "Produktgruppe"
|
||||
},
|
||||
"value_type": "int",
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": true,
|
||||
|
|
@ -68,7 +128,7 @@
|
|||
"en": "Product Type",
|
||||
"de": "Produkttyp"
|
||||
},
|
||||
"value_type": "int",
|
||||
"value_type": 1,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": true,
|
||||
|
|
@ -83,13 +143,26 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "hc-code",
|
||||
"l11n": {
|
||||
"en": "HC-code",
|
||||
"de": "Zolltarifnummer"
|
||||
},
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": true,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": []
|
||||
},
|
||||
{
|
||||
"name": "color",
|
||||
"l11n": {
|
||||
"en": "Color",
|
||||
"de": "Farbe"
|
||||
},
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
|
|
@ -138,7 +211,7 @@
|
|||
"en": "Length",
|
||||
"de": "Laenge"
|
||||
},
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": true,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
|
|
@ -147,7 +220,7 @@
|
|||
},
|
||||
{
|
||||
"name": "weight",
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": true,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
|
|
@ -164,7 +237,7 @@
|
|||
"en": "Country of origin",
|
||||
"de": "Herkunftsland"
|
||||
},
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": true,
|
||||
|
|
@ -177,7 +250,7 @@
|
|||
"en": "License",
|
||||
"de": "Lizenz"
|
||||
},
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
|
|
@ -190,7 +263,7 @@
|
|||
"en": "Platform",
|
||||
"de": "Plattform"
|
||||
},
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
|
|
@ -228,7 +301,7 @@
|
|||
"en": "Operating System",
|
||||
"de": "Betriebssystem"
|
||||
},
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
|
|
@ -259,14 +332,14 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "os_version",
|
||||
"l11n": {
|
||||
"en": "Operating System Version",
|
||||
"de": "Betriebssystem Version"
|
||||
},
|
||||
"value_type": "string",
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": false,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
|
|
|
|||
|
|
@ -45,6 +45,66 @@
|
|||
"default": null,
|
||||
"foreignTable": "itemmgmt_item",
|
||||
"foreignKey": "itemmgmt_item_id"
|
||||
},
|
||||
"itemmgmt_item_unit": {
|
||||
"name": "itemmgmt_item_unit",
|
||||
"type": "INT",
|
||||
"default": null,
|
||||
"null": true,
|
||||
"foreignTable": "organization_unit",
|
||||
"foreignKey": "organization_unit_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"itemmgmt_item_relation_type": {
|
||||
"description": "Items can be related in many ways e.g. expansions, services, successor, tools, spare parts, materials",
|
||||
"name": "itemmgmt_item_relation_type",
|
||||
"fields": {
|
||||
"itemmgmt_item_relation_type_id": {
|
||||
"name": "itemmgmt_item_relation_type_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"itemmgmt_item_relation_type_title": {
|
||||
"name": "itemmgmt_item_relation_type_title",
|
||||
"type": "VARCHAR(30)",
|
||||
"null": false,
|
||||
"unique": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"itemmgmt_item_relation": {
|
||||
"name": "itemmgmt_item_relation",
|
||||
"fields": {
|
||||
"itemmgmt_item_relation_id": {
|
||||
"name": "itemmgmt_item_relation_id",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"primary": true,
|
||||
"autoincrement": true
|
||||
},
|
||||
"itemmgmt_item_relation_type": {
|
||||
"name": "itemmgmt_item_relation_type",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "itemmgmt_item_relation_type",
|
||||
"foreignKey": "itemmgmt_item_relation_type_id"
|
||||
},
|
||||
"itemmgmt_item_relation_src": {
|
||||
"name": "itemmgmt_item_relation_src",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "itemmgmt_item",
|
||||
"foreignKey": "itemmgmt_item_id"
|
||||
},
|
||||
"itemmgmt_item_relation_dst": {
|
||||
"name": "itemmgmt_item_relation_dst",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "itemmgmt_item",
|
||||
"foreignKey": "itemmgmt_item_id"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -60,7 +120,7 @@
|
|||
},
|
||||
"itemmgmt_item_l11n_type_title": {
|
||||
"name": "itemmgmt_item_l11n_type_title",
|
||||
"type": "VARCHAR(255)",
|
||||
"type": "VARCHAR(50)",
|
||||
"null": false
|
||||
},
|
||||
"itemmgmt_item_l11n_type_required": {
|
||||
|
|
@ -122,6 +182,12 @@
|
|||
"itemmgmt_attr_type_name": {
|
||||
"name": "itemmgmt_attr_type_name",
|
||||
"type": "VARCHAR(255)",
|
||||
"null": false,
|
||||
"unique": true
|
||||
},
|
||||
"itemmgmt_attr_type_datatype": {
|
||||
"name": "itemmgmt_attr_type_datatype",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"itemmgmt_attr_type_fields": {
|
||||
|
|
@ -194,11 +260,6 @@
|
|||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
},
|
||||
"itemmgmt_attr_value_valuetype": {
|
||||
"name": "itemmgmt_attr_value_valuetype",
|
||||
"type": "INT(11)",
|
||||
"null": false
|
||||
},
|
||||
"itemmgmt_attr_value_valueStr": {
|
||||
"name": "itemmgmt_attr_value_valueStr",
|
||||
"type": "VARCHAR(255)",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
[
|
||||
{
|
||||
"name": "name1",
|
||||
"is_required": true
|
||||
},
|
||||
{
|
||||
"name": "name2",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "info",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "description_short",
|
||||
"is_required": false
|
||||
},
|
||||
{
|
||||
"name": "description_long",
|
||||
"is_required": false
|
||||
}
|
||||
]
|
||||
29
Admin/Install/relations.json
Normal file
29
Admin/Install/relations.json
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[
|
||||
{
|
||||
"name": "spare_part"
|
||||
},
|
||||
{
|
||||
"name": "service"
|
||||
},
|
||||
{
|
||||
"name": "expansion"
|
||||
},
|
||||
{
|
||||
"name": "tool"
|
||||
},
|
||||
{
|
||||
"name": "material"
|
||||
},
|
||||
{
|
||||
"name": "successor"
|
||||
},
|
||||
{
|
||||
"name": "alternative"
|
||||
},
|
||||
{
|
||||
"name": "complementary"
|
||||
},
|
||||
{
|
||||
"name": "other"
|
||||
}
|
||||
]
|
||||
|
|
@ -47,22 +47,33 @@ final class Installer extends InstallerAbstract
|
|||
{
|
||||
parent::install($app, $info, $cfgHandler);
|
||||
|
||||
/* Attributes */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/attributes.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = \json_decode($fileContent);
|
||||
$attributes = \json_decode($fileContent, true);
|
||||
$attrTypes = self::createItemAttributeTypes($app, $attributes);
|
||||
self::createItemAttributeValues($app, $attrTypes, $attributes);
|
||||
$attrValues = self::createItemAttributeValues($app, $attrTypes, $attributes);
|
||||
|
||||
/* Localizations */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/localizations.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$localizations = \json_decode($fileContent);
|
||||
$localizations = \json_decode($fileContent, true);
|
||||
$l11nTypes = self::createItemL11nTypes($app, $localizations);
|
||||
|
||||
/* Relations */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/relations.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$relations = \json_decode($fileContent, true);
|
||||
$l11nTypes = self::createItemRelationTypes($app, $relations);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,7 +98,7 @@ final class Installer extends InstallerAbstract
|
|||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = \mt_rand(2, 5);
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n['name']);
|
||||
$request->setData('is_required', $l11n['is_required'] ?? false);
|
||||
|
||||
|
|
@ -106,6 +117,46 @@ final class Installer extends InstallerAbstract
|
|||
return $l11nTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install default relation types
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $relations Attribute definition
|
||||
*
|
||||
* @return array<array>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createItemRelationTypes(ApplicationAbstract $app, array $rels) : array
|
||||
{
|
||||
/** @var array<string, array> $relations */
|
||||
$relations = [];
|
||||
|
||||
/** @var \Modules\ItemManagement\Controller\ApiController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('ItemManagement');
|
||||
|
||||
foreach ($rels as $rel) {
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $rel['name']);
|
||||
|
||||
$module->apiItemRelationTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->get('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$relations[] = !\is_array($responseData['response'])
|
||||
? $responseData['response']->toArray()
|
||||
: $responseData['response'];
|
||||
}
|
||||
|
||||
return $relations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install default attribute types
|
||||
*
|
||||
|
|
@ -131,11 +182,12 @@ final class Installer extends InstallerAbstract
|
|||
|
||||
$request->header->account = 1;
|
||||
$request->setData('name', $attribute['name'] ?? '');
|
||||
$request->setData('title', $attribute['l11n'][0] ?? '');
|
||||
$request->setData('title', \reset($attribute['l11n']));
|
||||
$request->setData('language', \array_keys($attribute['l11n'])[0] ?? 'en');
|
||||
$request->setData('is_required', $attribute['is_required'] ?? false);
|
||||
$request->setData('is_custom_allowed', $attribute['is_custom_allowed'] ?? false);
|
||||
$request->setData('validation_pattern', $attribute['validation_pattern'] ?? '');
|
||||
$request->setData('datatype', (int) $attribute['value_type']);
|
||||
|
||||
$module->apiItemAttributeTypeCreate($request, $response);
|
||||
|
||||
|
|
@ -199,13 +251,12 @@ final class Installer extends InstallerAbstract
|
|||
|
||||
$request->header->account = 1;
|
||||
$request->setData('value', $value['value'] ?? '');
|
||||
$request->setData('value_type', $attribute['value_type'] ?? 0);
|
||||
$request->setData('unit', $value['unit'] ?? '');
|
||||
$request->setData('default', isset($attribute['values']) && !empty($attribute['values']));
|
||||
$request->setData('attributetype', $itemAttrType[$attribute['name']]['id']);
|
||||
|
||||
if (isset($value['l11n']) && !empty($value['l11n'])) {
|
||||
$request->setData('title', $value['l11n'][0] ?? '');
|
||||
$request->setData('title', \reset($value['l11n']));
|
||||
$request->setData('language', \array_keys($value['l11n'])[0] ?? 'en');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,17 +18,18 @@ use Modules\ItemManagement\Models\Item;
|
|||
use Modules\ItemManagement\Models\ItemAttribute;
|
||||
use Modules\ItemManagement\Models\ItemAttributeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeType;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeL11n;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeL11nMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValue;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValueL11n;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValueL11nMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValueMapper;
|
||||
use Modules\ItemManagement\Models\ItemL11n;
|
||||
use Modules\ItemManagement\Models\ItemL11nMapper;
|
||||
use Modules\ItemManagement\Models\ItemL11nType;
|
||||
use Modules\ItemManagement\Models\ItemL11nTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemRelationType;
|
||||
use Modules\ItemManagement\Models\ItemRelationTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemMapper;
|
||||
use Modules\ItemManagement\Models\ItemPrice;
|
||||
use Modules\ItemManagement\Models\ItemPriceStatus;
|
||||
|
|
@ -78,7 +79,11 @@ final class ApiController extends Controller
|
|||
}
|
||||
|
||||
$item = $this->createItemFromRequest($request);
|
||||
|
||||
$this->app->dbPool->get()->con->beginTransaction();
|
||||
$this->createModel($request->header->account, $item, ItemMapper::class, 'item', $request->getOrigin());
|
||||
$this->app->dbPool->get()->con->commit();
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Item', 'Item successfully created', $item);
|
||||
}
|
||||
|
||||
|
|
@ -99,6 +104,7 @@ final class ApiController extends Controller
|
|||
$item->purchasePrice = new Money($request->getData('purchaseprice', 'int') ?? 0);
|
||||
$item->info = (string) ($request->getData('info') ?? '');
|
||||
$item->parent = ($request->getData('parent') !== null) ? (int) $request->getData('parent') : null;
|
||||
$item->unit = ($request->getData('unit') !== null) ? (int) $request->getData('unit') : null;
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
|
@ -314,18 +320,18 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return ItemAttributeTypeL11n
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createItemAttributeTypeL11nFromRequest(RequestAbstract $request) : ItemAttributeTypeL11n
|
||||
private function createItemAttributeTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$attrL11n = new ItemAttributeTypeL11n();
|
||||
$attrL11n->type = (int) ($request->getData('type') ?? 0);
|
||||
$attrL11n = new BaseStringL11n();
|
||||
$attrL11n->ref = (int) ($request->getData('type') ?? 0);
|
||||
$attrL11n->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
$attrL11n->title = (string) ($request->getData('title') ?? '');
|
||||
$attrL11n->content = (string) ($request->getData('title') ?? '');
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
|
@ -392,6 +398,7 @@ final class ApiController extends Controller
|
|||
{
|
||||
$attrType = new ItemAttributeType($request->getData('name') ?? '');
|
||||
$attrType->setL11n((string) ($request->getData('title') ?? ''), $request->getData('language') ?? ISO639x1Enum::_EN);
|
||||
$attrType->datatype = (int) ($request->getData('datatype') ?? 0);
|
||||
$attrType->setFields((int) ($request->getData('fields') ?? 0));
|
||||
$attrType->custom = (bool) ($request->getData('custom') ?? false);
|
||||
$attrType->isRequired = (bool) ($request->getData('is_required') ?? false);
|
||||
|
|
@ -449,7 +456,7 @@ final class ApiController extends Controller
|
|||
if ($attrValue->isDefault) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('attributetype'),
|
||||
(int) $request->getData('type'),
|
||||
$attrValue->getId(),
|
||||
ItemAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
|
||||
);
|
||||
|
|
@ -469,10 +476,13 @@ final class ApiController extends Controller
|
|||
*/
|
||||
private function createItemAttributeValueFromRequest(RequestAbstract $request) : ItemAttributeValue
|
||||
{
|
||||
$type = (int) ($request->getData('type') ?? 0);
|
||||
$type = ItemAttributeTypeMapper::get()
|
||||
->where('id', (int) ($request->getData('type') ?? 0))
|
||||
->execute();
|
||||
|
||||
$attrValue = new ItemAttributeValue($type, $request->getData('value'));
|
||||
$attrValue = new ItemAttributeValue();
|
||||
$attrValue->isDefault = (bool) ($request->getData('default') ?? false);
|
||||
$attrValue->setValue($request->getData('value'), $type->datatype);
|
||||
|
||||
if ($request->getData('title') !== null) {
|
||||
$attrValue->setL11n($request->getData('title'), $request->getData('language') ?? ISO639x1Enum::_EN);
|
||||
|
|
@ -534,18 +544,18 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return ItemAttributeValueL11n
|
||||
* @return BaseStringL11n
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createItemAttributeValueL11nFromRequest(RequestAbstract $request) : ItemAttributeValueL11n
|
||||
private function createItemAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$attrL11n = new ItemAttributeValueL11n();
|
||||
$attrL11n->value = (int) ($request->getData('value') ?? 0);
|
||||
$attrL11n = new BaseStringL11n();
|
||||
$attrL11n->ref = (int) ($request->getData('value') ?? 0);
|
||||
$attrL11n->setLanguage((string) (
|
||||
$request->getData('language') ?? $request->getLanguage()
|
||||
));
|
||||
$attrL11n->title = (string) ($request->getData('title') ?? '');
|
||||
$attrL11n->content = (string) ($request->getData('title') ?? '');
|
||||
|
||||
return $attrL11n;
|
||||
}
|
||||
|
|
@ -635,6 +645,69 @@ final class ApiController extends Controller
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create item l11n type
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiItemRelationTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateItemRelationTypeCreate($request))) {
|
||||
$response->set('item_relation_type_create', new FormValidation($val));
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$itemRelationType = $this->createItemRelationTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $itemRelationType, ItemRelationTypeMapper::class, 'item_relation_type', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Item relation type', 'Item relation type successfully created', $itemRelationType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create item l11n type from request.
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return ItemRelationType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createItemRelationTypeFromRequest(RequestAbstract $request) : ItemRelationType
|
||||
{
|
||||
$itemRelationType = new ItemRelationType();
|
||||
$itemRelationType->title = (string) ($request->getData('title') ?? '');
|
||||
|
||||
return $itemRelationType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate item l11n type create request
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return array<string, bool>
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function validateItemRelationTypeCreate(RequestAbstract $request) : array
|
||||
{
|
||||
$val = [];
|
||||
if (($val['title'] = empty($request->getData('title')))) {
|
||||
return $val;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create item l11n
|
||||
*
|
||||
|
|
|
|||
|
|
@ -101,6 +101,14 @@ class Item
|
|||
|
||||
public string $info = '';
|
||||
|
||||
/**
|
||||
* Unit
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $unit = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
@ -237,6 +245,47 @@ class Item
|
|||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Has attribute value
|
||||
*
|
||||
* @param string $attrName Attribute name
|
||||
* @param mixed $attrValue Attribute value
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function hasAttributeValue(string $attrName, mixed $attrValue) : bool
|
||||
{
|
||||
foreach ($this->attributes as $attribute) {
|
||||
if ($attribute->type->name === $attrName && $attribute->value->getValue() === $attrValue) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attribute
|
||||
*
|
||||
* @param string $attrName Attribute name
|
||||
*
|
||||
* @return null|AttributeValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttribute(string $attrName) : ?AttributeValue
|
||||
{
|
||||
foreach ($this->attributes as $attribute) {
|
||||
if ($attribute->type->name === $attrName) {
|
||||
return $attribute->value;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add note to item
|
||||
*
|
||||
|
|
@ -295,6 +344,26 @@ class Item
|
|||
return new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media files by type name
|
||||
*
|
||||
* @param string $type Media type
|
||||
*
|
||||
* @return Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFileByTypeName(string $type) : Media
|
||||
{
|
||||
foreach ($this->files as $file) {
|
||||
if ($file->type->name === $type) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullMedia();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all media files by type
|
||||
*
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Item Attribute Type class.
|
||||
|
|
@ -62,12 +63,20 @@ class ItemAttributeType implements \JsonSerializable
|
|||
|
||||
public bool $isRequired = false;
|
||||
|
||||
/**
|
||||
* Datatype of the attribute
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $datatype = AttributeValueType::_STRING;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var ItemAttributeTypeL11n
|
||||
* @var BaseStringL11n
|
||||
*/
|
||||
private string | ItemAttributeTypeL11n $l11n = '';
|
||||
private string | BaseStringL11n $l11n = '';
|
||||
|
||||
/**
|
||||
* Possible default attribute values
|
||||
|
|
@ -111,22 +120,22 @@ class ItemAttributeType implements \JsonSerializable
|
|||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|ItemAttributeTypeL11n $l11n Tag article l11n
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | ItemAttributeTypeL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof ItemAttributeTypeL11n) {
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof ItemAttributeTypeL11n) {
|
||||
$this->l11n->title = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
} else {
|
||||
$this->l11n = new ItemAttributeTypeL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
|
@ -138,7 +147,7 @@ class ItemAttributeType implements \JsonSerializable
|
|||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
return $this->l11n instanceof ItemAttributeTypeL11n ? $this->l11n->title : $this->l11n;
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Item class.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ItemAttributeTypeL11n implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Item ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $type;
|
||||
|
||||
/**
|
||||
* Language.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $type Attribute type
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $type = 0, string $title = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->title = $title;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getLanguage() : string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'type' => $this->type,
|
||||
'language' => $this->language,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Item mapper class.
|
||||
|
|
@ -34,8 +35,8 @@ final class ItemAttributeTypeL11nMapper extends DataMapperFactory
|
|||
*/
|
||||
public const COLUMNS = [
|
||||
'itemmgmt_attr_type_l11n_id' => ['name' => 'itemmgmt_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'itemmgmt_attr_type_l11n_title' => ['name' => 'itemmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'itemmgmt_attr_type_l11n_type' => ['name' => 'itemmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'itemmgmt_attr_type_l11n_title' => ['name' => 'itemmgmt_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'itemmgmt_attr_type_l11n_type' => ['name' => 'itemmgmt_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'itemmgmt_attr_type_l11n_lang' => ['name' => 'itemmgmt_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
|
|
@ -54,4 +55,12 @@ final class ItemAttributeTypeL11nMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD ='itemmgmt_attr_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ final class ItemAttributeTypeMapper extends DataMapperFactory
|
|||
public const COLUMNS = [
|
||||
'itemmgmt_attr_type_id' => ['name' => 'itemmgmt_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'itemmgmt_attr_type_name' => ['name' => 'itemmgmt_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'itemmgmt_attr_type_datatype' => ['name' => 'itemmgmt_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'],
|
||||
'itemmgmt_attr_type_fields' => ['name' => 'itemmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'itemmgmt_attr_type_custom' => ['name' => 'itemmgmt_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'itemmgmt_attr_type_pattern' => ['name' => 'itemmgmt_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Item attribute value class.
|
||||
|
|
@ -36,14 +37,6 @@ class ItemAttributeValue implements \JsonSerializable
|
|||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Datatype of the attribute
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $type = 0;
|
||||
|
||||
/**
|
||||
* Int value
|
||||
*
|
||||
|
|
@ -95,24 +88,9 @@ class ItemAttributeValue implements \JsonSerializable
|
|||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var null|ItemAttributeValueL11n
|
||||
* @var null|BaseStringL11n
|
||||
*/
|
||||
private ?ItemAttributeValueL11n $l11n = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $type Type
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $type = 0, mixed $value = '')
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
$this->setValue($value);
|
||||
}
|
||||
private ?BaseStringL11n $l11n = null;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
|
|
@ -129,22 +107,23 @@ class ItemAttributeValue implements \JsonSerializable
|
|||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|ItemAttributeValueL11n $l11n Tag article l11n
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | ItemAttributeValueL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof ItemAttributeValueL11n) {
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof ItemAttributeValueL11n) {
|
||||
$this->l11n->title = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
} else {
|
||||
$this->l11n = new ItemAttributeValueL11n();
|
||||
$this->l11n->title = $l11n;
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->ref = $this->id;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
|
@ -158,28 +137,29 @@ class ItemAttributeValue implements \JsonSerializable
|
|||
*/
|
||||
public function getL11n() : ?string
|
||||
{
|
||||
return $this->l11n instanceof ItemAttributeValueL11n ? $this->l11n->title : $this->l11n;
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int|string|float|\DateTimeInterface $value Value
|
||||
* @param int $type Datatype
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValue(mixed $value) : void
|
||||
public function setValue(mixed $value, int $datatype) : void
|
||||
{
|
||||
if (\is_string($value)) {
|
||||
$this->valueStr = $value;
|
||||
} elseif (\is_int($value)) {
|
||||
$this->valueInt = $value;
|
||||
} elseif (\is_float($value)) {
|
||||
$this->valueDec = $value;
|
||||
} elseif ($value instanceof \DateTimeInterface) {
|
||||
$this->valueDat = $value;
|
||||
if ($datatype === AttributeValueType::_STRING) {
|
||||
$this->valueStr = (string) $value;
|
||||
} elseif ($datatype === AttributeValueType::_INT) {
|
||||
$this->valueInt = (int) $value;
|
||||
} elseif ($datatype === AttributeValueType::_FLOAT) {
|
||||
$this->valueDec = (float) $value;
|
||||
} elseif ($datatype === AttributeValueType::_DATETIME) {
|
||||
$this->valueDat = new \DateTime($value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,7 +192,6 @@ class ItemAttributeValue implements \JsonSerializable
|
|||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'valueInt' => $this->valueInt,
|
||||
'valueStr' => $this->valueStr,
|
||||
'valueDec' => $this->valueDec,
|
||||
|
|
|
|||
|
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Item class.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ItemAttributeValueL11n implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Item ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $value;
|
||||
|
||||
/**
|
||||
* Language.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $language = ISO639x1Enum::_EN;
|
||||
|
||||
/**
|
||||
* Title.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $value Attribute value
|
||||
* @param string $title Localized title
|
||||
* @param string $language Language
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $value = 0, string $title = '', string $language = ISO639x1Enum::_EN)
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->title = $title;
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get language
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getLanguage() : string
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set language
|
||||
*
|
||||
* @param string $language Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setLanguage(string $language) : void
|
||||
{
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
'value' => $this->value,
|
||||
'language' => $this->language,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Item mapper class.
|
||||
|
|
@ -34,8 +35,8 @@ final class ItemAttributeValueL11nMapper extends DataMapperFactory
|
|||
*/
|
||||
public const COLUMNS = [
|
||||
'itemmgmt_attr_value_l11n_id' => ['name' => 'itemmgmt_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'itemmgmt_attr_value_l11n_title' => ['name' => 'itemmgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true],
|
||||
'itemmgmt_attr_value_l11n_value' => ['name' => 'itemmgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'value'],
|
||||
'itemmgmt_attr_value_l11n_title' => ['name' => 'itemmgmt_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'itemmgmt_attr_value_l11n_value' => ['name' => 'itemmgmt_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
|
||||
'itemmgmt_attr_value_l11n_lang' => ['name' => 'itemmgmt_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
|
|
@ -54,4 +55,12 @@ final class ItemAttributeValueL11nMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD ='itemmgmt_attr_value_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ final class ItemAttributeValueMapper extends DataMapperFactory
|
|||
public const COLUMNS = [
|
||||
'itemmgmt_attr_value_id' => ['name' => 'itemmgmt_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'itemmgmt_attr_value_default' => ['name' => 'itemmgmt_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'itemmgmt_attr_value_valuetype' => ['name' => 'itemmgmt_attr_value_valuetype', 'type' => 'int', 'internal' => 'type'],
|
||||
'itemmgmt_attr_value_valueStr' => ['name' => 'itemmgmt_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'itemmgmt_attr_value_valueInt' => ['name' => 'itemmgmt_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'itemmgmt_attr_value_valueDec' => ['name' => 'itemmgmt_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
|
|
@ -53,8 +52,7 @@ final class ItemAttributeValueMapper extends DataMapperFactory
|
|||
'l11n' => [
|
||||
'mapper' => ItemAttributeValueL11nMapper::class,
|
||||
'table' => 'itemmgmt_attr_value_l11n',
|
||||
'self' => 'itemmgmt_attr_value_l11n_type',
|
||||
'column' => 'title',
|
||||
'self' => 'itemmgmt_attr_value_l11n_value',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ final class ItemMapper extends DataMapperFactory
|
|||
'itemmgmt_item_salesprice' => ['name' => 'itemmgmt_item_salesprice', 'type' => 'Serializable', 'internal' => 'salesPrice'],
|
||||
'itemmgmt_item_purchaseprice' => ['name' => 'itemmgmt_item_purchaseprice', 'type' => 'Serializable', 'internal' => 'purchasePrice'],
|
||||
'itemmgmt_item_parent' => ['name' => 'itemmgmt_item_parent', 'type' => 'int', 'internal' => 'parent'],
|
||||
'itemmgmt_item_unit' => ['name' => 'itemmgmt_item_unit', 'type' => 'int', 'internal' => 'unit'],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
91
Models/ItemRelation.php
Normal file
91
Models/ItemRelation.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
/**
|
||||
* Item relation
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ItemRelation implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Article ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Item source.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $source = 0;
|
||||
|
||||
/**
|
||||
* Item destination.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $destination = 0;
|
||||
|
||||
/**
|
||||
* Relation type.
|
||||
*
|
||||
* @var ItemRelationType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ItemRelationType $type;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ItemRelationType $type Item relation type
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(ItemRelationType $type = null)
|
||||
{
|
||||
$this->type = $type ?? new ItemRelationType();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'source' => $this->source,
|
||||
'destination' => $this->destination,
|
||||
'type' => $this->type,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
70
Models/ItemRelationMapper.php
Normal file
70
Models/ItemRelationMapper.php
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Item mapper class.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ItemRelationMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'itemmgmt_item_relation_id' => ['name' => 'itemmgmt_item_relation_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'itemmgmt_item_relation_src' => ['name' => 'itemmgmt_item_relation_src', 'type' => 'int', 'internal' => 'source'],
|
||||
'itemmgmt_item_relation_dst' => ['name' => 'itemmgmt_item_relation_dst', 'type' => 'int', 'internal' => 'destination'],
|
||||
'itemmgmt_item_relation_type' => ['name' => 'itemmgmt_item_relation_type', 'type' => 'int', 'internal' => 'type'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
'type' => [
|
||||
'mapper' => ItemRelationTypeMapper::class,
|
||||
'external' => 'itemmgmt_item_relation_type',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'itemmgmt_item_relation';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD ='itemmgmt_item_relation_id';
|
||||
}
|
||||
61
Models/ItemRelationType.php
Normal file
61
Models/ItemRelationType.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
/**
|
||||
* Item relation type.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ItemRelationType implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Article ID.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Identifier for the l11n type.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $title = '';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'title' => $this->title,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
55
Models/ItemRelationTypeMapper.php
Normal file
55
Models/ItemRelationTypeMapper.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Item mapper class.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ItemRelationTypeMapper extends DataMapperFactory
|
||||
{
|
||||
/**
|
||||
* Columns.
|
||||
*
|
||||
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'itemmgmt_item_relation_type_id' => ['name' => 'itemmgmt_item_relation_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'itemmgmt_item_relation_type_title' => ['name' => 'itemmgmt_item_relation_type_title', 'type' => 'string', 'internal' => 'title'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'itemmgmt_item_relation_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD ='itemmgmt_item_relation_type_id';
|
||||
}
|
||||
3
Models/NullItemAttributeTypeL11n.php → Models/NullItemRelation.php
Executable file → Normal file
3
Models/NullItemAttributeTypeL11n.php → Models/NullItemRelation.php
Executable file → Normal file
|
|
@ -22,7 +22,7 @@ namespace Modules\ItemManagement\Models;
|
|||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullItemAttributeTypeL11n extends ItemAttributeTypeL11n
|
||||
final class NullItemRelation extends ItemRelation
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -34,7 +34,6 @@ final class NullItemAttributeTypeL11n extends ItemAttributeTypeL11n
|
|||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
46
Models/NullItemRelationType.php
Normal file
46
Models/NullItemRelationType.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
/**
|
||||
* Null model
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 1.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullItemRelationType extends ItemRelationType
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<tbody>
|
||||
<?php $count = 0; foreach ($items as $key => $value) : ++$count;
|
||||
$url = UriFactory::build('{/lang}/{/app}/sales/item/profile?{?}&id=' . $value->getId());
|
||||
$image = $value->getFileByType(0);
|
||||
$image = $value->getFileByTypeName('item_profile_image');
|
||||
?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="<?= $url; ?>"><img alt="<?= $this->getHtml('IMG_alt_item'); ?>" width="30" loading="lazy" class="item-image"
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ trait ApiControllerAttributeTrait
|
|||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('attributetype', '1');
|
||||
$request->setData('type', AttributeValueType::_STRING);
|
||||
$request->setData('value', '1');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
|
|
@ -144,6 +145,7 @@ trait ApiControllerAttributeTrait
|
|||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('attributetype', '1');
|
||||
$request->setData('type', AttributeValueType::_FLOAT);
|
||||
$request->setData('value', '1.1');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
|
|
@ -163,6 +165,7 @@ trait ApiControllerAttributeTrait
|
|||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('attributetype', '1');
|
||||
$request->setData('type', AttributeValueType::_DATETIME);
|
||||
$request->setData('value', '2020-08-02');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
|
|
|
|||
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ItemAttributeTypeL11nTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private ItemAttributeTypeL11n $l11n;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->l11n = new ItemAttributeTypeL11n();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeTypeL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->l11n->getId());
|
||||
self::assertEquals('', $this->l11n->title);
|
||||
self::assertEquals(0, $this->l11n->type);
|
||||
self::assertEquals(ISO639x1Enum::_EN, $this->l11n->getLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeTypeL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testNameInputOutput() : void
|
||||
{
|
||||
$this->l11n->title = 'TestName';
|
||||
self::assertEquals('TestName', $this->l11n->title);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeTypeL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testLanguageInputOutput() : void
|
||||
{
|
||||
$this->l11n->setLanguage(ISO639x1Enum::_DE);
|
||||
self::assertEquals(ISO639x1Enum::_DE, $this->l11n->getLanguage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeTypeL11n
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->l11n->title = 'Title';
|
||||
$this->l11n->type = 2;
|
||||
$this->l11n->setLanguage(ISO639x1Enum::_DE);
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'title' => 'Title',
|
||||
'type' => 2,
|
||||
'language' => ISO639x1Enum::_DE,
|
||||
],
|
||||
$this->l11n->jsonSerialize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\ItemAttributeType;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeL11n;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
|
@ -55,7 +55,7 @@ final class ItemAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
$this->attr->setL11n('Test');
|
||||
self::assertEquals('Test', $this->attr->getL11n());
|
||||
|
||||
$this->attr->setL11n(new ItemAttributeTypeL11n(0, 'NewTest'));
|
||||
$this->attr->setL11n(new BaseStringL11n('NewTest'));
|
||||
self::assertEquals('NewTest', $this->attr->getL11n());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,20 +15,21 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\ItemAttributeValue;
|
||||
use Modules\ItemManagement\Models\AttributeValueType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private ItemAttributeValue $attr;
|
||||
private ItemAttributeValue $value;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->attr = new ItemAttributeValue();
|
||||
$this->value = new ItemAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -37,10 +38,9 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->attr->getId());
|
||||
self::assertEquals(0, $this->attr->type);
|
||||
self::assertNull($this->attr->getValue());
|
||||
self::assertFalse($this->attr->isDefault);
|
||||
self::assertEquals(0, $this->value->getId());
|
||||
self::assertNull($this->value->getValue());
|
||||
self::assertFalse($this->value->isDefault);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -49,8 +49,8 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testValueIntInputOutput() : void
|
||||
{
|
||||
$this->attr->setValue(1);
|
||||
self::assertEquals(1, $this->attr->getValue());
|
||||
$this->value->setValue(1, AttributeValueType::_INT);
|
||||
self::assertEquals(1, $this->value->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -59,8 +59,8 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testValueFloatInputOutput() : void
|
||||
{
|
||||
$this->attr->setValue(1.1);
|
||||
self::assertEquals(1.1, $this->attr->getValue());
|
||||
$this->value->setValue(1.1, AttributeValueType::_FLOAT);
|
||||
self::assertEquals(1.1, $this->value->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -69,8 +69,8 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testValueStringInputOutput() : void
|
||||
{
|
||||
$this->attr->setValue('test');
|
||||
self::assertEquals('test', $this->attr->getValue());
|
||||
$this->value->setValue('test', AttributeValueType::_STRING);
|
||||
self::assertEquals('test', $this->value->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -79,8 +79,9 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testValueDateInputOutput() : void
|
||||
{
|
||||
$this->attr->setValue($dat = new \DateTime('now'));
|
||||
self::assertEquals($dat->format('Y-m-d'), $this->attr->getValue()->format('Y-m-d'));
|
||||
$dat = new \DateTime('now');
|
||||
$this->value->setValue('now', AttributeValueType::_DATETIME);
|
||||
self::assertEquals($dat->format('Y-m-d'), $this->value->getValue()->format('Y-m-d'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -89,21 +90,19 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testSerialize() : void
|
||||
{
|
||||
$this->attr->type = 1;
|
||||
$this->attr->setValue('test');
|
||||
$this->attr->isDefault = true;
|
||||
$this->value->setValue('test', AttributeValueType::_STRING);
|
||||
$this->value->isDefault = true;
|
||||
|
||||
self::assertEquals(
|
||||
[
|
||||
'id' => 0,
|
||||
'type' => 1,
|
||||
'valueInt' => null,
|
||||
'valueStr' => 'test',
|
||||
'valueDec' => null,
|
||||
'valueDat' => null,
|
||||
'isDefault' => true,
|
||||
],
|
||||
$this->attr->jsonSerialize()
|
||||
$this->value->jsonSerialize()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package tests
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\NullItemAttributeTypeL11n;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullItemAttributeTypeL11nTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttributeTypeL11n
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\ItemManagement\Models\ItemAttributeTypeL11n', new NullItemAttributeTypeL11n());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttributeTypeL11n
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullItemAttributeTypeL11n(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user