new datamapper mostly implemented

This commit is contained in:
Dennis Eichhorn 2021-12-11 11:54:17 +01:00
parent 478cdffe28
commit 75340bbe28
15 changed files with 109 additions and 101 deletions

View File

@ -68,9 +68,9 @@ final class Installer extends InstallerAbstract
$itemAttrType = [];
$itemAttrType['color'] = new ItemAttributeType('color'); // @todo: I think 'color' in this case is a ItemAttributeTypeL11n, this is wrong?!
ItemAttributeTypeMapper::create($itemAttrType['color']);
ItemAttributeTypeL11nMapper::create(new ItemAttributeTypeL11n($itemAttrType['color']->getId(), 'Color', ISO639x1Enum::_EN));
ItemAttributeTypeL11nMapper::create(new ItemAttributeTypeL11n($itemAttrType['color']->getId(), 'Farbe', ISO639x1Enum::_DE));
ItemAttributeTypeMapper::create()->execute($itemAttrType['color']);
ItemAttributeTypeL11nMapper::create()->execute(new ItemAttributeTypeL11n($itemAttrType['color']->getId(), 'Color', ISO639x1Enum::_EN));
ItemAttributeTypeL11nMapper::create()->execute(new ItemAttributeTypeL11n($itemAttrType['color']->getId(), 'Farbe', ISO639x1Enum::_DE));
// weight
// segment_level_1
@ -103,92 +103,92 @@ final class Installer extends InstallerAbstract
$itemAttrValue['color'] = [];
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Red', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][0]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][0]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Rot', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][1]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][1]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Blue', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][2]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][2]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Blau', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][3]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][3]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Green', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][4]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][4]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Grün', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][5]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][5]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Yellow', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][6]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][6]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Gelb', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][7]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][7]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'White', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][8]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][8]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Weiss', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][9]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][9]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Black', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][10]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][10]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Schwarz', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][11]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][11]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Braun', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][12]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][12]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Braun', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][13]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][13]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Purple', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][14]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][14]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Lila', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][15]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][15]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Pink', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][16]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][16]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Rosa', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][17]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][17]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Orange', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][18]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][18]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Orange', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][19]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][19]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Grey', ISO639x1Enum::_EN);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][20]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][20]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
$itemAttrValue['color'][] = new ItemAttributeValue(AttributeValueType::_STRING, 'Grau', ISO639x1Enum::_DE);
$id = ItemAttributeValueMapper::create($itemAttrValue['color'][21]);
ItemAttributeTypeMapper::createRelation('defaults', $itemAttrType['color']->getId(), $id);
$id = ItemAttributeValueMapper::create()->execute($itemAttrValue['color'][21]);
ItemAttributeTypeMapper::writer()->createRelationTable('defaults', [$id], $itemAttrType['color']->getId());
return $itemAttrValue;
}

View File

@ -168,12 +168,22 @@ final class BackendController extends Controller
$view->setTemplate('/Modules/ItemManagement/Theme/Backend/sales-item-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004805001, $request, $response));
$items = ItemMapper::getAll()
->with('l11n')
->with('l11n/type')
->where('l11n/language', $response->getLanguage())
->where('l11n/type', ['name1', 'name2', 'name3'], 'IN')
->limit(25)
->execute();
/*
$items = ItemMapper::with('language', $response->getLanguage())
::with('type', 'backend_image', models: [Media::class]) // @todo: it would be nicer if I coult say files:type or files/type and remove the models parameter?
::with('notes', models: null)
::with('attributes', models: null)
::with('title', ['name1', 'name2', 'name3'], comparison: 'in', models: [ItemL11nType::class]) // @todo: profile, why does this have almost no impact on the sql performance?
::getAfterPivot(0, null, 25);
*/
$view->addData('items', $items);
@ -324,7 +334,7 @@ final class BackendController extends Controller
SettingsEnum::DEFAULT_LOCALIZATION,
]);
$view->setData('defaultlocalization', LocalizationMapper::get((int) $settings['id']));
$view->setData('defaultlocalization', LocalizationMapper::get()->where('id', (int) $settings['id']))->execute();
$itemL11n = ItemL11nMapper::with('language', $response->getLanguage())
::with('item', $item->getId())::getAll();

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Item mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class ItemAttributeMapper extends DataMapperAbstract
final class ItemAttributeMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class ItemAttributeMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
public const COLUMNS = [
'itemmgmt_item_attr_id' => ['name' => 'itemmgmt_item_attr_id', 'type' => 'int', 'internal' => 'id'],
'itemmgmt_item_attr_item' => ['name' => 'itemmgmt_item_attr_item', 'type' => 'int', 'internal' => 'item'],
'itemmgmt_item_attr_type' => ['name' => 'itemmgmt_item_attr_type', 'type' => 'int', 'internal' => 'type'],
@ -45,7 +45,7 @@ final class ItemAttributeMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
protected static array $ownsOne = [
public const OWNS_ONE = [
'type' => [
'mapper' => ItemAttributeTypeMapper::class,
'external' => 'itemmgmt_item_attr_type',
@ -62,7 +62,7 @@ final class ItemAttributeMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_item_attr';
public const TABLE = 'itemmgmt_item_attr';
/**
* Primary field name.
@ -70,5 +70,5 @@ final class ItemAttributeMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_item_attr_id';
public const PRIMARYFIELD ='itemmgmt_item_attr_id';
}

View File

@ -38,10 +38,10 @@ class ItemAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
/**
* Item ID.
*
* @var int|ItemAttributeType
* @var ItemAttributeType
* @since 1.0.0
*/
public int | ItemAttributeType $type = 0;
public ItemAttributeType $type;
/**
* Language.
@ -62,15 +62,15 @@ class ItemAttributeTypeL11n implements \JsonSerializable, ArrayableInterface
/**
* Constructor.
*
* @param int|ItemAttributeType $type Attribute type
* @param ItemAttributeType $type Attribute type
* @param string $title Localized title
* @param string $language Language
*
* @since 1.0.0
*/
public function __construct(int | ItemAttributeType $type = 0, string $title = '', string $language = ISO639x1Enum::_EN)
public function __construct(ItemAttributeType $type = null, string $title = '', string $language = ISO639x1Enum::_EN)
{
$this->type = $type;
$this->type = $type ?? new ItemAttributeType();;
$this->title = $title;
$this->language = $language;
}

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Item mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class ItemAttributeTypeL11nMapper extends DataMapperAbstract
final class ItemAttributeTypeL11nMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class ItemAttributeTypeL11nMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
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'],
@ -45,7 +45,7 @@ final class ItemAttributeTypeL11nMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_attr_type_l11n';
public const TABLE = 'itemmgmt_attr_type_l11n';
/**
* Primary field name.
@ -53,5 +53,5 @@ final class ItemAttributeTypeL11nMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_attr_type_l11n_id';
public const PRIMARYFIELD ='itemmgmt_attr_type_l11n_id';
}

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Item mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class ItemAttributeTypeMapper extends DataMapperAbstract
final class ItemAttributeTypeMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class ItemAttributeTypeMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
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_fields' => ['name' => 'itemmgmt_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
@ -47,21 +47,19 @@ final class ItemAttributeTypeMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
public const HAS_MANY = [
'l11n' => [
'mapper' => ItemAttributeTypeL11nMapper::class,
'table' => 'itemmgmt_attr_type_l11n',
'self' => 'itemmgmt_attr_type_l11n_type',
'column' => 'title',
'conditional' => true,
'external' => null,
],
'defaults' => [
'mapper' => ItemAttributeValueMapper::class,
'table' => 'itemmgmt_item_attr_default',
'self' => 'itemmgmt_item_attr_default_type',
'external' => 'itemmgmt_item_attr_default_value',
'conditional' => false,
'external' => 'itemmgmt_item_attr_default_value'
],
];
@ -71,7 +69,7 @@ final class ItemAttributeTypeMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_attr_type';
public const TABLE = 'itemmgmt_attr_type';
/**
* Primary field name.
@ -79,5 +77,5 @@ final class ItemAttributeTypeMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_attr_type_id';
public const PRIMARYFIELD ='itemmgmt_attr_type_id';
}

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Item mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https: //orange-management.org
* @since 1.0.0
*/
final class ItemAttributeValueMapper extends DataMapperAbstract
final class ItemAttributeValueMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class ItemAttributeValueMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
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_type' => ['name' => 'itemmgmt_attr_value_type', 'type' => 'int', 'internal' => 'type'],
@ -50,7 +50,7 @@ final class ItemAttributeValueMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_attr_value';
public const TABLE = 'itemmgmt_attr_value';
/**
* Primary field name.
@ -58,5 +58,5 @@ final class ItemAttributeValueMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_attr_value_id';
public const PRIMARYFIELD ='itemmgmt_attr_value_id';
}

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Item mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class ItemL11nMapper extends DataMapperAbstract
final class ItemL11nMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class ItemL11nMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
public const COLUMNS = [
'itemmgmt_item_l11n_id' => ['name' => 'itemmgmt_item_l11n_id', 'type' => 'int', 'internal' => 'id'],
'itemmgmt_item_l11n_description' => ['name' => 'itemmgmt_item_l11n_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true],
'itemmgmt_item_l11n_item' => ['name' => 'itemmgmt_item_l11n_item', 'type' => 'int', 'internal' => 'item'],
@ -46,7 +46,7 @@ final class ItemL11nMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
* @since 1.0.0
*/
protected static array $ownsOne = [
public const OWNS_ONE = [
'type' => [
'mapper' => ItemL11nTypeMapper::class,
'external' => 'itemmgmt_item_l11n_typeref',
@ -59,7 +59,7 @@ final class ItemL11nMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_item_l11n';
public const TABLE = 'itemmgmt_item_l11n';
/**
* Primary field name.
@ -67,5 +67,5 @@ final class ItemL11nMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_item_l11n_id';
public const PRIMARYFIELD ='itemmgmt_item_l11n_id';
}

View File

@ -14,7 +14,7 @@ declare(strict_types=1);
namespace Modules\ItemManagement\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Item mapper class.
@ -24,7 +24,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class ItemL11nTypeMapper extends DataMapperAbstract
final class ItemL11nTypeMapper extends DataMapperFactory
{
/**
* Columns.
@ -32,7 +32,7 @@ final class ItemL11nTypeMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
public const COLUMNS = [
'itemmgmt_item_l11n_type_id' => ['name' => 'itemmgmt_item_l11n_type_id', 'type' => 'int', 'internal' => 'id'],
'itemmgmt_item_l11n_type_title' => ['name' => 'itemmgmt_item_l11n_type_title', 'type' => 'string', 'internal' => 'title'],
];
@ -43,7 +43,7 @@ final class ItemL11nTypeMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_item_l11n_type';
public const TABLE = 'itemmgmt_item_l11n_type';
/**
* Primary field name.
@ -51,5 +51,5 @@ final class ItemL11nTypeMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_item_l11n_type_id';
public const PRIMARYFIELD ='itemmgmt_item_l11n_type_id';
}

View File

@ -16,7 +16,7 @@ namespace Modules\ItemManagement\Models;
use Modules\Editor\Models\EditorDocMapper;
use Modules\Media\Models\MediaMapper;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
/**
* Item mapper class.
@ -26,7 +26,7 @@ use phpOMS\DataStorage\Database\DataMapperAbstract;
* @link https://orange-management.org
* @since 1.0.0
*/
final class ItemMapper extends DataMapperAbstract
final class ItemMapper extends DataMapperFactory
{
/**
* Columns.
@ -34,7 +34,7 @@ final class ItemMapper extends DataMapperAbstract
* @var array<string, array{name:string, type:string, internal:string, autocomplete?:bool, readonly?:bool, writeonly?:bool, annotations?:array}>
* @since 1.0.0
*/
protected static array $columns = [
public const COLUMNS = [
'itemmgmt_item_id' => ['name' => 'itemmgmt_item_id', 'type' => 'int', 'internal' => 'id'],
'itemmgmt_item_no' => ['name' => 'itemmgmt_item_no', 'type' => 'string', 'internal' => 'number', 'autocomplete' => true],
'itemmgmt_item_status' => ['name' => 'itemmgmt_item_status', 'type' => 'int', 'internal' => 'status'],
@ -53,7 +53,7 @@ final class ItemMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'itemmgmt_item';
public const TABLE = 'itemmgmt_item';
/**
* Primary field name.
@ -61,7 +61,7 @@ final class ItemMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'itemmgmt_item_id';
public const PRIMARYFIELD ='itemmgmt_item_id';
/**
* Has many relation.
@ -69,7 +69,7 @@ final class ItemMapper extends DataMapperAbstract
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
* @since 1.0.0
*/
protected static array $hasMany = [
public const HAS_MANY = [
'files' => [
'mapper' => MediaMapper::class, /* mapper of the related object */
'table' => 'itemmgmt_item_media', /* table of the related object, null if no relation table is used (many->1) */
@ -86,14 +86,12 @@ final class ItemMapper extends DataMapperAbstract
'mapper' => ItemL11nMapper::class,
'table' => 'itemmgmt_item_l11n',
'self' => 'itemmgmt_item_l11n_item',
'conditional' => true,
'external' => null,
],
'attributes' => [
'mapper' => ItemAttributeMapper::class,
'table' => 'itemmgmt_item_attr',
'self' => 'itemmgmt_item_attr_item',
'conditional' => true,
'external' => null,
],
];

View File

@ -34,5 +34,6 @@ final class NullItemAttributeTypeL11n extends ItemAttributeTypeL11n
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -34,5 +34,6 @@ final class NullItemL11n extends ItemL11n
public function __construct(int $id = 0)
{
$this->id = $id;
parent::__construct();
}
}

View File

@ -130,7 +130,7 @@ echo $this->getData('nav')->render(); ?>
<tbody>
<?php $count = 0; foreach ($items as $key => $value) : ++$count;
$url = UriFactory::build('{/prefix}sales/item/profile?{?}&id=' . $value->getId());
$image = $value->getFileByType('backend_image');
$image = $value->getFileByType(0);
?>
<tr data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><img width="30" loading="lazy" class="item-image"

View File

@ -12,7 +12,7 @@ require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/Autoloader.php';
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
use phpOMS\DataStorage\Session\HttpSession;
$CONFIG = [
@ -329,7 +329,7 @@ $GLOBALS['dbpool']->create('delete', $CONFIG['db']['core']['masters']['delete'])
$GLOBALS['dbpool']->create('insert', $CONFIG['db']['core']['masters']['insert']);
$GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema']);
DataMapperAbstract::setConnection($GLOBALS['dbpool']->get());
DataMapperFactory::db($GLOBALS['dbpool']->get());
$GLOBALS['frameworkpath'] = '/phpOMS/';

View File

@ -31,7 +31,7 @@ final class ItemMapperTest extends \PHPUnit\Framework\TestCase
$item = new Item();
$item->number = '123456789';
$id = ItemMapper::create($item);
$id = ItemMapper::create()->execute($item);
self::assertGreaterThan(0, $item->getId());
self::assertEquals($id, $item->getId());
}