mirror of
https://github.com/Karaka-Management/oms-ItemManagement.git
synced 2026-02-01 05:08:41 +00:00
fix static analysis
This commit is contained in:
parent
3e6d0cfc3c
commit
5d05b4e242
|
|
@ -14,8 +14,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\Admin;
|
||||
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValue;
|
||||
use Modules\Attribute\Models\AttributeTypeMapper;
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use Modules\ItemManagement\Models\ItemL11nTypeMapper;
|
||||
use phpOMS\Application\ApplicationAbstract;
|
||||
use phpOMS\Config\SettingsInterface;
|
||||
|
|
@ -58,8 +58,8 @@ final class Installer extends InstallerAbstract
|
|||
|
||||
/** @var array $attributes */
|
||||
$attributes = \json_decode($fileContent, true);
|
||||
$attrTypes = self::createItemAttributeTypes($app, $attributes);
|
||||
$attrValues = self::createItemAttributeValues($app, $attrTypes, $attributes);
|
||||
$attrTypes = self::createAttributeTypes($app, $attributes);
|
||||
$attrValues = self::createAttributeValues($app, $attrTypes, $attributes);
|
||||
|
||||
/* Localizations */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/localizations.json');
|
||||
|
|
@ -109,8 +109,8 @@ final class Installer extends InstallerAbstract
|
|||
/** @var \Modules\ItemManagement\Controller\ApiController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('ItemManagement');
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\ItemAttributeType[] $attributeTypes */
|
||||
$attributeTypes = ItemAttributeTypeMapper::getAll()->with('defaults')->execute();
|
||||
/** @var \Modules\Attribute\Models\AttributeType[] $attributeTypes */
|
||||
$attributeTypes = AttributeTypeMapper::getAll()->with('defaults')->execute();
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\ItemL11nType[] $l11nTypes */
|
||||
$l11nTypes = ItemL11nTypeMapper::getAll()->execute();
|
||||
|
|
@ -187,8 +187,8 @@ final class Installer extends InstallerAbstract
|
|||
/**
|
||||
* Find attribute IDs by value
|
||||
*
|
||||
* @param ItemAttributeValue[] $defaultValues Values to search in
|
||||
* @param mixed $value Value to search for
|
||||
* @param AttributeValue[] $defaultValues Values to search in
|
||||
* @param mixed $value Value to search for
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
|
|
@ -299,7 +299,7 @@ final class Installer extends InstallerAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createItemAttributeTypes(ApplicationAbstract $app, array $attributes) : array
|
||||
private static function createAttributeTypes(ApplicationAbstract $app, array $attributes) : array
|
||||
{
|
||||
/** @var array<string, array> $itemAttrType */
|
||||
$itemAttrType = [];
|
||||
|
|
@ -365,7 +365,7 @@ final class Installer extends InstallerAbstract
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createItemAttributeValues(ApplicationAbstract $app, array $itemAttrType, array $attributes) : array
|
||||
private static function createAttributeValues(ApplicationAbstract $app, array $itemAttrType, array $attributes) : array
|
||||
{
|
||||
/** @var array<string, array> $itemAttrValue */
|
||||
$itemAttrValue = [];
|
||||
|
|
|
|||
|
|
@ -15,14 +15,15 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\Controller;
|
||||
|
||||
use Modules\Admin\Models\NullAccount;
|
||||
use Modules\Billing\Models\PricingMapper;
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use Modules\Attribute\Models\NullAttributeType;
|
||||
use Modules\Attribute\Models\NullAttributeValue;
|
||||
use Modules\ItemManagement\Models\Item;
|
||||
use Modules\ItemManagement\Models\ItemAttribute;
|
||||
use Modules\ItemManagement\Models\ItemAttributeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeType;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeL11nMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValue;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValueL11nMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValueMapper;
|
||||
use Modules\ItemManagement\Models\ItemL11n;
|
||||
|
|
@ -35,8 +36,6 @@ use Modules\ItemManagement\Models\ItemPriceStatus;
|
|||
use Modules\ItemManagement\Models\ItemRelationType;
|
||||
use Modules\ItemManagement\Models\ItemRelationTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemStatus;
|
||||
use Modules\ItemManagement\Models\NullItemAttributeType;
|
||||
use Modules\ItemManagement\Models\NullItemAttributeValue;
|
||||
use Modules\ItemManagement\Models\NullItemL11nType;
|
||||
use Modules\Media\Models\Collection;
|
||||
use Modules\Media\Models\CollectionMapper;
|
||||
|
|
@ -54,18 +53,17 @@ use phpOMS\Message\NotificationLevel;
|
|||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Model\Message\FormValidation;
|
||||
use phpOMS\Module\NullModule;
|
||||
use phpOMS\System\MimeType;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
|
||||
/**
|
||||
* ItemManagement class.
|
||||
Item* ItemManagement class.
|
||||
*
|
||||
* @package Modules\ItemManagement
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
Item*/
|
||||
final class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
|
|
@ -83,6 +81,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiItemFind(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
/** @var \Modules\ItemManagement\Models\ItemL11n[] $l11n */
|
||||
$l11n = ItemL11nMapper::getAll()
|
||||
->with('type')
|
||||
->where('type/title', ['name1', 'name2', 'name3'], 'IN')
|
||||
|
|
@ -95,18 +94,19 @@ final class ApiController extends Controller
|
|||
$items[] = $item->item;
|
||||
}
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\Item[] $itemList */
|
||||
$itemList = ItemMapper::getAll()
|
||||
->with('l11n')
|
||||
->with('l11n/type')
|
||||
->where('id', $items, 'IN')
|
||||
->where('l11n/type/title', ['name1', 'name2', 'name3'], 'IN')
|
||||
->where('l11n/language', $request->getLanguage())
|
||||
->execute();
|
||||
|
||||
$response->header->set('Content-Type', MimeType::M_JSON, true);
|
||||
$response->set(
|
||||
$request->uri->__toString(),
|
||||
\array_values(
|
||||
ItemMapper::getAll()
|
||||
->with('l11n')
|
||||
->with('l11n/type')
|
||||
->where('id', $items, 'IN')
|
||||
->where('l11n/type/title', ['name1', 'name2', 'name3'], 'IN')
|
||||
->where('l11n/language', $request->getLanguage())
|
||||
->execute()
|
||||
)
|
||||
\array_values($itemList)
|
||||
);
|
||||
|
||||
/*
|
||||
|
|
@ -201,6 +201,7 @@ final class ApiController extends Controller
|
|||
);
|
||||
|
||||
// create type / media relation
|
||||
/** @var \Modules\Media\Models\MediaType $profileImageType */
|
||||
$profileImageType = MediaTypeMapper::get()
|
||||
->where('name', 'item_profile_image')
|
||||
->execute();
|
||||
|
|
@ -403,23 +404,23 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return ItemAttribute
|
||||
* @return Attribute
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createItemAttributeFromRequest(RequestAbstract $request) : ItemAttribute
|
||||
private function createItemAttributeFromRequest(RequestAbstract $request) : Attribute
|
||||
{
|
||||
$attribute = new ItemAttribute();
|
||||
$attribute->item = (int) $request->getData('item');
|
||||
$attribute->type = new NullItemAttributeType((int) $request->getData('type'));
|
||||
$attribute = new Attribute();
|
||||
$attribute->ref = (int) $request->getData('item');
|
||||
$attribute->type = new NullAttributeType((int) $request->getData('type'));
|
||||
|
||||
if ($request->hasData('value')) {
|
||||
$attribute->value = new NullItemAttributeValue((int) $request->getData('value'));
|
||||
$attribute->value = new NullAttributeValue((int) $request->getData('value'));
|
||||
} else {
|
||||
$newRequest = clone $request;
|
||||
$newRequest->setData('value', $request->getData('custom'), true);
|
||||
|
||||
$value = $this->createItemAttributeValueFromRequest($newRequest);
|
||||
$value = $this->createAttributeValueFromRequest($newRequest);
|
||||
|
||||
$attribute->value = $value;
|
||||
}
|
||||
|
|
@ -540,7 +541,7 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$attrType = $this->createItemAttributeTypeFromRequest($request);
|
||||
$attrType = $this->createAttributeTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrType, ItemAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
|
||||
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type', 'Attribute type successfully created', $attrType);
|
||||
|
|
@ -551,13 +552,13 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return ItemAttributeType
|
||||
* @return AttributeType
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createItemAttributeTypeFromRequest(RequestAbstract $request) : ItemAttributeType
|
||||
private function createAttributeTypeFromRequest(RequestAbstract $request) : AttributeType
|
||||
{
|
||||
$attrType = new ItemAttributeType($request->getDataString('name') ?? '');
|
||||
$attrType = new AttributeType($request->getDataString('name') ?? '');
|
||||
$attrType->datatype = $request->getDataInt('datatype') ?? 0;
|
||||
$attrType->custom = $request->getDataBool('custom') ?? false;
|
||||
$attrType->isRequired = (bool) ($request->getData('is_required') ?? false);
|
||||
|
|
@ -611,7 +612,7 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$attrValue = $this->createItemAttributeValueFromRequest($request);
|
||||
$attrValue = $this->createAttributeValueFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrValue, ItemAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
|
||||
if ($attrValue->isDefault) {
|
||||
|
|
@ -631,18 +632,18 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @param RequestAbstract $request Request
|
||||
*
|
||||
* @return ItemAttributeValue
|
||||
* @return AttributeValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createItemAttributeValueFromRequest(RequestAbstract $request) : ItemAttributeValue
|
||||
private function createAttributeValueFromRequest(RequestAbstract $request) : AttributeValue
|
||||
{
|
||||
/** @var ItemAttributeType $type */
|
||||
/** @var AttributeType $type */
|
||||
$type = ItemAttributeTypeMapper::get()
|
||||
->where('id', $request->getDataInt('type') ?? 0)
|
||||
->execute();
|
||||
|
||||
$attrValue = new ItemAttributeValue();
|
||||
$attrValue = new AttributeValue();
|
||||
$attrValue->isDefault = $request->getDataBool('default') ?? false;
|
||||
$attrValue->setValue($request->getData('value'), $type->datatype);
|
||||
|
||||
|
|
@ -696,7 +697,7 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createItemAttributeValueL11nFromRequest($request);
|
||||
$attrL11n = $this->createAttributeValueL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, ItemAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Localization', 'Localization successfully created', $attrL11n);
|
||||
}
|
||||
|
|
@ -710,7 +711,7 @@ final class ApiController extends Controller
|
|||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private function createItemAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
private function createAttributeValueL11nFromRequest(RequestAbstract $request) : BaseStringL11n
|
||||
{
|
||||
$attrL11n = new BaseStringL11n();
|
||||
$attrL11n->ref = $request->getDataInt('value') ?? 0;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ use Modules\Admin\Models\LocalizationMapper;
|
|||
use Modules\Admin\Models\SettingsEnum;
|
||||
use Modules\Billing\Models\BillTransferType;
|
||||
use Modules\Billing\Models\SalesBillMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeTypeMapper;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValueMapper;
|
||||
use Modules\Attribute\Models\AttributeTypeMapper;
|
||||
use Modules\Attribute\Models\AttributeValueMapper;
|
||||
use Modules\ItemManagement\Models\ItemMapper;
|
||||
use phpOMS\Asset\AssetType;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
|
|
@ -61,8 +61,8 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/ItemManagement/Theme/Backend/attribute-type-list');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\ItemAttributeType[] $attributes */
|
||||
$attributes = ItemAttributeTypeMapper::getAll()
|
||||
/** @var \Modules\Attribute\Models\AttributeType[] $attributes */
|
||||
$attributes = AttributeTypeMapper::getAll()
|
||||
->with('l11n')
|
||||
->where('l11n/language', $response->getLanguage())
|
||||
->execute();
|
||||
|
|
@ -90,8 +90,8 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/ItemManagement/Theme/Backend/attribute-value-list');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\ItemAttributeValue[] $attributes */
|
||||
$attributes = ItemAttributeValueMapper::getAll()
|
||||
/** @var \Modules\Attribute\Models\AttributeValue[] $attributes */
|
||||
$attributes = AttributeValueMapper::getAll()
|
||||
->with('l11n')
|
||||
->where('l11n/language', $response->getLanguage())
|
||||
->execute();
|
||||
|
|
@ -119,8 +119,8 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/ItemManagement/Theme/Backend/attribute-type');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\ItemAttributeType $attribute */
|
||||
$attribute = ItemAttributeTypeMapper::get()
|
||||
/** @var \Modules\Attribute\Models\AttributeType $attribute */
|
||||
$attribute = AttributeTypeMapper::get()
|
||||
->with('l11n')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('l11n/language', $response->getLanguage())
|
||||
|
|
@ -149,8 +149,8 @@ final class BackendController extends Controller
|
|||
$view->setTemplate('/Modules/ItemManagement/Theme/Backend/attribute-value');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1004801001, $request, $response));
|
||||
|
||||
/** @var \Modules\ItemManagement\Models\ItemAttributeValue $attribute */
|
||||
$attribute = ItemAttributeValueMapper::get()
|
||||
/** @var \Modules\Attribute\Models\AttributeValue $attribute */
|
||||
$attribute = AttributeValueMapper::get()
|
||||
->with('l11n')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->where('l11n/language', $response->getLanguage())
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\Stdlib\Base\Enum;
|
||||
|
||||
/**
|
||||
* Attribute value type enum.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
abstract class AttributeValueType extends Enum
|
||||
{
|
||||
public const _INT = 1;
|
||||
|
||||
public const _STRING = 2;
|
||||
|
||||
public const _FLOAT = 3;
|
||||
|
||||
public const _DATETIME = 4;
|
||||
|
||||
public const _BOOL = 5;
|
||||
|
||||
public const _FLOAT_INT = 6;
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ class Item implements \JsonSerializable
|
|||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var ItemAttribute[]
|
||||
* @var \Modules\Attribute\Models\Attribute[]
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $attributes = [];
|
||||
|
|
@ -225,73 +225,6 @@ class Item implements \JsonSerializable
|
|||
$this->files[] = $media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attribute to item
|
||||
*
|
||||
* @param ItemAttribute $attribute Note
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function addAttribute(ItemAttribute $attribute) : void
|
||||
{
|
||||
$this->attributes[] = $attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get attributes
|
||||
*
|
||||
* @return ItemAttribute[]
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttributes() : array
|
||||
{
|
||||
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|ItemAttribute
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getAttribute(string $attrName) : ?ItemAttribute
|
||||
{
|
||||
foreach ($this->attributes as $attribute) {
|
||||
if ($attribute->type->name === $attrName) {
|
||||
return $attribute;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add note to item
|
||||
*
|
||||
|
|
@ -412,4 +345,6 @@ class Item implements \JsonSerializable
|
|||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
use \Modules\Attribute\Models\AttributeHolderTrait;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
/**
|
||||
* Item class.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ItemAttribute implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Id.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Item this attribute belongs to
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $item = 0;
|
||||
|
||||
/**
|
||||
* Attribute type the attribute belongs to
|
||||
*
|
||||
* @var ItemAttributeType
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ItemAttributeType $type;
|
||||
|
||||
/**
|
||||
* Attribute value the attribute belongs to
|
||||
*
|
||||
* @var ItemAttributeValue
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ItemAttributeValue $value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = new NullItemAttributeType();
|
||||
$this->value = new NullItemAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'item' => $this->item,
|
||||
'type' => $this->type,
|
||||
'value' => $this->value,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +35,7 @@ final class ItemAttributeMapper extends DataMapperFactory
|
|||
*/
|
||||
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_item' => ['name' => 'itemmgmt_item_attr_item', 'type' => 'int', 'internal' => 'ref'],
|
||||
'itemmgmt_item_attr_type' => ['name' => 'itemmgmt_item_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'itemmgmt_item_attr_value' => ['name' => 'itemmgmt_item_attr_value', 'type' => 'int', 'internal' => 'value'],
|
||||
];
|
||||
|
|
@ -56,6 +57,14 @@ final class ItemAttributeMapper extends DataMapperFactory
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = Attribute::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,239 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Item Attribute Type class.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ItemAttributeType implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Name/string identifier by which it can be found/categorized
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Which field data type is required (string, int, ...) in the value
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $fields = 0;
|
||||
|
||||
/**
|
||||
* Is a custom value allowed (e.g. custom string)
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $custom = false;
|
||||
|
||||
/**
|
||||
* Validation pattern for the value
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $validationPattern = '';
|
||||
|
||||
/**
|
||||
* Is the attribute required
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $isRequired = false;
|
||||
|
||||
/**
|
||||
* Datatype of the attribute
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $datatype = AttributeValueType::_STRING;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var string|BaseStringL11n
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private string | BaseStringL11n $l11n = '';
|
||||
|
||||
/**
|
||||
* Possible default attribute values
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private array $defaults = [];
|
||||
|
||||
/**
|
||||
* Default attribute value
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $default = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $name Name/identifier of the attribute type
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(string $name = '')
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default value by value
|
||||
*
|
||||
* @param mixed $value Value
|
||||
*
|
||||
* @return ItemAttributeValue
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getDefaultByValue(mixed $value) : ItemAttributeValue
|
||||
{
|
||||
foreach ($this->defaults as $default) {
|
||||
if ($default->getValue() === $value) {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullItemAttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
} else {
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : string
|
||||
{
|
||||
if (!isset($this->l11n)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set fields
|
||||
*
|
||||
* @param int $fields Fields
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFields(int $fields) : void
|
||||
{
|
||||
$this->fields = $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default values
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @sicne 1.0.0
|
||||
*/
|
||||
public function getDefaults() : array
|
||||
{
|
||||
return $this->defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'validationPattern' => $this->validationPattern,
|
||||
'custom' => $this->custom,
|
||||
'isRequired' => $this->isRequired,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
|
|
@ -64,6 +65,14 @@ final class ItemAttributeTypeMapper extends DataMapperFactory
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = AttributeType::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,230 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Localization\ISO639x1Enum;
|
||||
|
||||
/**
|
||||
* Item attribute value class.
|
||||
*
|
||||
* The relation with the type/item is defined in the ItemAttribute class.
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class ItemAttributeValue implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected int $id = 0;
|
||||
|
||||
/**
|
||||
* Depending attribute type
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $dependingAttributeType = null;
|
||||
|
||||
/**
|
||||
* Depending attribute value
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $dependingAttributeValue = null;
|
||||
|
||||
/**
|
||||
* Int value
|
||||
*
|
||||
* @var null|int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?int $valueInt = null;
|
||||
|
||||
/**
|
||||
* String value
|
||||
*
|
||||
* @var null|string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?string $valueStr = null;
|
||||
|
||||
/**
|
||||
* Decimal value
|
||||
*
|
||||
* @var null|float
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?float $valueDec = null;
|
||||
|
||||
/**
|
||||
* DateTime value
|
||||
*
|
||||
* @var null|\DateTimeInterface
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?\DateTimeInterface $valueDat = null;
|
||||
|
||||
/**
|
||||
* Is a default value which can be selected
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public bool $isDefault = false;
|
||||
|
||||
/**
|
||||
* Unit of the value
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $unit = '';
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
* @var null|BaseStringL11n
|
||||
*/
|
||||
private ?BaseStringL11n $l11n = null;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set l11n
|
||||
*
|
||||
* @param string|BaseStringL11n $l11n Tag article l11n
|
||||
* @param string $lang Language
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setL11n(string | BaseStringL11n $l11n, string $lang = ISO639x1Enum::_EN) : void
|
||||
{
|
||||
if ($l11n instanceof BaseStringL11n) {
|
||||
$this->l11n = $l11n;
|
||||
} elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) {
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->setLanguage($lang);
|
||||
} else {
|
||||
$this->l11n = new BaseStringL11n();
|
||||
$this->l11n->content = $l11n;
|
||||
$this->l11n->ref = $this->id;
|
||||
$this->l11n->setLanguage($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get localization
|
||||
*
|
||||
* @return null|string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getL11n() : ?string
|
||||
{
|
||||
return $this->l11n instanceof BaseStringL11n ? $this->l11n->content : $this->l11n;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set value
|
||||
*
|
||||
* @param int|string|float $value Value
|
||||
* @param int $datatype Datatype
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setValue(mixed $value, int $datatype) : void
|
||||
{
|
||||
if ($datatype === AttributeValueType::_STRING) {
|
||||
$this->valueStr = (string) $value;
|
||||
} elseif ($datatype === AttributeValueType::_INT
|
||||
|| $datatype === AttributeValueType::_FLOAT_INT
|
||||
|| $datatype === AttributeValueType::_BOOL
|
||||
) {
|
||||
$this->valueInt = (int) $value;
|
||||
} elseif ($datatype === AttributeValueType::_FLOAT) {
|
||||
$this->valueDec = (float) $value;
|
||||
} elseif ($datatype === AttributeValueType::_DATETIME) {
|
||||
$this->valueDat = new \DateTime((string) $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value
|
||||
*
|
||||
* @return null|int|string|float|\DateTimeInterface
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getValue() : mixed
|
||||
{
|
||||
if (!empty($this->valueStr)) {
|
||||
return $this->valueStr;
|
||||
} elseif (!empty($this->valueInt)) {
|
||||
return $this->valueInt;
|
||||
} elseif (!empty($this->valueDec)) {
|
||||
return $this->valueDec;
|
||||
} elseif ($this->valueDat instanceof \DateTimeInterface) {
|
||||
return $this->valueDat;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'valueInt' => $this->valueInt,
|
||||
'valueStr' => $this->valueStr,
|
||||
'valueDec' => $this->valueDec,
|
||||
'valueDat' => $this->valueDat,
|
||||
'isDefault' => $this->isDefault,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
|
|
@ -59,6 +60,14 @@ final class ItemAttributeValueMapper extends DataMapperFactory
|
|||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = AttributeValue::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\Models;
|
||||
|
||||
use Modules\Attribute\Models\AttributeMapper;
|
||||
use Modules\Editor\Models\EditorDocMapper;
|
||||
use Modules\Media\Models\MediaMapper;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
|
@ -87,7 +88,7 @@ final class ItemMapper extends DataMapperFactory
|
|||
'external' => null,
|
||||
],
|
||||
'attributes' => [
|
||||
'mapper' => ItemAttributeMapper::class,
|
||||
'mapper' => AttributeMapper::class,
|
||||
'table' => 'itemmgmt_item_attr',
|
||||
'self' => 'itemmgmt_item_attr_item',
|
||||
'external' => null,
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.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 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullItemAttribute extends ItemAttribute
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param int $id Model id
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct(int $id = 0)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function jsonSerialize() : mixed
|
||||
{
|
||||
return ['id' => $this->id];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.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 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullItemAttributeType extends ItemAttributeType
|
||||
{
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\ItemManagement\Models
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.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 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class NullItemAttributeValue extends ItemAttributeValue
|
||||
{
|
||||
/**
|
||||
* 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];
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ use phpOMS\Uri\UriFactory;
|
|||
$item = $this->getData('item');
|
||||
|
||||
$itemL11n = $item->getL11ns();
|
||||
$itemAttribute = $item->getAttributes();
|
||||
$Attribute = $item->getAttributes();
|
||||
|
||||
$notes = $item->getNotes();
|
||||
$files = $item->getFiles();
|
||||
|
|
@ -549,7 +549,7 @@ echo $this->getData('nav')->render();
|
|||
<td class="wf-100"><?= $this->getHtml('Name'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
||||
<tbody>
|
||||
<?php $c = 0;
|
||||
foreach ($itemAttribute as $key => $value) : ++$c;
|
||||
foreach ($Attribute as $key => $value) : ++$c;
|
||||
$url = UriFactory::build('{/base}/admin/group/settings?{?}&id=' . $value->getId()); ?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="#"><i class="fa fa-times"></i></a>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use phpOMS\Uri\UriFactory;
|
|||
$item = $this->getData('item');
|
||||
|
||||
$itemL11n = $item->getL11ns();
|
||||
$itemAttribute = $item->getAttributes();
|
||||
$Attribute = $item->getAttributes();
|
||||
|
||||
$notes = $item->getNotes();
|
||||
$files = $item->getFiles();
|
||||
|
|
@ -547,7 +547,7 @@ echo $this->getData('nav')->render();
|
|||
<td class="wf-100"><?= $this->getHtml('Name'); ?><i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
|
||||
<tbody>
|
||||
<?php $c = 0;
|
||||
foreach ($itemAttribute as $key => $value) : ++$c;
|
||||
foreach ($Attribute as $key => $value) : ++$c;
|
||||
$url = UriFactory::build('{/base}/admin/group/settings?{?}&id=' . $value->getId()); ?>
|
||||
<tr data-href="<?= $url; ?>">
|
||||
<td><a href="#"><i class="fa fa-times"></i></a>
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ trait ApiControllerAttributeTrait
|
|||
$request->setData('title', 'EN:1');
|
||||
$request->setData('language', ISO639x1Enum::_EN);
|
||||
|
||||
$this->module->apiItemAttributeTypeCreate($request, $response);
|
||||
$this->module->apiAttributeTypeCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->getId());
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ trait ApiControllerAttributeTrait
|
|||
$request->setData('type', '1');
|
||||
$request->setData('language', ISO639x1Enum::_DE);
|
||||
|
||||
$this->module->apiItemAttributeTypeL11nCreate($request, $response);
|
||||
$this->module->apiAttributeTypeL11nCreate($request, $response);
|
||||
self::assertGreaterThan(0, $response->get('')['response']->getId());
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ trait ApiControllerAttributeTrait
|
|||
$request->header->account = 1;
|
||||
$request->setData('invalid', '1');
|
||||
|
||||
$this->module->apiItemAttributeTypeCreate($request, $response);
|
||||
$this->module->apiAttributeTypeCreate($request, $response);
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
|
||||
}
|
||||
|
||||
|
|
@ -235,7 +235,7 @@ trait ApiControllerAttributeTrait
|
|||
$request->header->account = 1;
|
||||
$request->setData('invalid', '1');
|
||||
|
||||
$this->module->apiItemAttributeTypeL11nCreate($request, $response);
|
||||
$this->module->apiAttributeTypeL11nCreate($request, $response);
|
||||
self::assertEquals(RequestStatusCode::R_400, $response->header->status);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,36 +14,36 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\ItemAttribute;
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ItemAttributeTest extends \PHPUnit\Framework\TestCase
|
||||
final class AttributeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private ItemAttribute $attr;
|
||||
private Attribute $attr;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->attr = new ItemAttribute();
|
||||
$this->attr = new Attribute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttribute
|
||||
* @covers Modules\Attribute\Models\Attribute
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
{
|
||||
self::assertEquals(0, $this->attr->getId());
|
||||
self::assertInstanceOf('Modules\ItemManagement\Models\ItemAttributeType', $this->attr->type);
|
||||
self::assertInstanceOf('Modules\ItemManagement\Models\ItemAttributeValue', $this->attr->value);
|
||||
self::assertInstanceOf('Modules\Attribute\Models\AttributeType', $this->attr->type);
|
||||
self::assertInstanceOf('Modules\Attribute\Models\AttributeValue', $this->attr->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttribute
|
||||
* @covers Modules\Attribute\Models\Attribute
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
|
|
|
|||
|
|
@ -14,26 +14,26 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\ItemAttributeType;
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ItemAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
final class AttributeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private ItemAttributeType $attr;
|
||||
private AttributeType $attr;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->attr = new ItemAttributeType();
|
||||
$this->attr = new AttributeType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeType
|
||||
* @covers Modules\Attribute\Models\AttributeType
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
|
|
@ -47,7 +47,7 @@ final class ItemAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeType
|
||||
* @covers Modules\Attribute\Models\AttributeType
|
||||
* @group module
|
||||
*/
|
||||
public function testL11nInputOutput() : void
|
||||
|
|
@ -60,7 +60,7 @@ final class ItemAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeType
|
||||
* @covers Modules\Attribute\Models\AttributeType
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
|
|
|
|||
|
|
@ -15,25 +15,25 @@ declare(strict_types=1);
|
|||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\AttributeValueType;
|
||||
use Modules\ItemManagement\Models\ItemAttributeValue;
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
final class AttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
private ItemAttributeValue $value;
|
||||
private AttributeValue $value;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() : void
|
||||
{
|
||||
$this->value = new ItemAttributeValue();
|
||||
$this->value = new AttributeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeValue
|
||||
* @covers Modules\Attribute\Models\AttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testDefault() : void
|
||||
|
|
@ -44,7 +44,7 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeValue
|
||||
* @covers Modules\Attribute\Models\AttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueIntInputOutput() : void
|
||||
|
|
@ -54,7 +54,7 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeValue
|
||||
* @covers Modules\Attribute\Models\AttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueFloatInputOutput() : void
|
||||
|
|
@ -64,7 +64,7 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeValue
|
||||
* @covers Modules\Attribute\Models\AttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueStringInputOutput() : void
|
||||
|
|
@ -74,7 +74,7 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeValue
|
||||
* @covers Modules\Attribute\Models\AttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testValueDateInputOutput() : void
|
||||
|
|
@ -85,7 +85,7 @@ final class ItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\ItemAttributeValue
|
||||
* @covers Modules\Attribute\Models\AttributeValue
|
||||
* @group module
|
||||
*/
|
||||
public function testSerialize() : void
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Modules\ItemManagement\tests\Models;
|
|||
|
||||
use Modules\Editor\Models\EditorDoc;
|
||||
use Modules\ItemManagement\Models\Item;
|
||||
use Modules\ItemManagement\Models\ItemAttribute;
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
use Modules\ItemManagement\Models\ItemL11n;
|
||||
use Modules\ItemManagement\Models\ItemStatus;
|
||||
use Modules\Media\Models\Media;
|
||||
|
|
@ -91,7 +91,7 @@ final class ItemTest extends \PHPUnit\Framework\TestCase
|
|||
*/
|
||||
public function testAttributeInputOutput() : void
|
||||
{
|
||||
$this->item->addAttribute(new ItemAttribute());
|
||||
$this->item->addAttribute(new Attribute());
|
||||
self::assertCount(1, $this->item->getAttributes());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,29 +14,29 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\NullItemAttribute;
|
||||
use Modules\ItemManagement\Models\NullAttribute;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullItemAttributeTest extends \PHPUnit\Framework\TestCase
|
||||
final class NullAttributeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttribute
|
||||
* @covers Modules\ItemManagement\Models\NullAttribute
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\ItemManagement\Models\ItemAttribute', new NullItemAttribute());
|
||||
self::assertInstanceOf('\Modules\Attribute\Models\Attribute', new NullAttribute());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttribute
|
||||
* @covers Modules\ItemManagement\Models\NullAttribute
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullItemAttribute(2);
|
||||
$null = new NullAttribute(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,29 +14,29 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\NullItemAttributeType;
|
||||
use Modules\ItemManagement\Models\NullAttributeType;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullItemAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
final class NullAttributeTypeTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttributeType
|
||||
* @covers Modules\ItemManagement\Models\NullAttributeType
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\ItemManagement\Models\ItemAttributeType', new NullItemAttributeType());
|
||||
self::assertInstanceOf('\Modules\Attribute\Models\AttributeType', new NullAttributeType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttributeType
|
||||
* @covers Modules\ItemManagement\Models\NullAttributeType
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullItemAttributeType(2);
|
||||
$null = new NullAttributeType(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,29 +14,29 @@ declare(strict_types=1);
|
|||
|
||||
namespace Modules\ItemManagement\tests\Models;
|
||||
|
||||
use Modules\ItemManagement\Models\NullItemAttributeValue;
|
||||
use Modules\ItemManagement\Models\NullAttributeValue;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class NullItemAttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
final class NullAttributeValueTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttributeValue
|
||||
* @covers Modules\ItemManagement\Models\NullAttributeValue
|
||||
* @group framework
|
||||
*/
|
||||
public function testNull() : void
|
||||
{
|
||||
self::assertInstanceOf('\Modules\ItemManagement\Models\ItemAttributeValue', new NullItemAttributeValue());
|
||||
self::assertInstanceOf('\Modules\Attribute\Models\AttributeValue', new NullAttributeValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\ItemManagement\Models\NullItemAttributeValue
|
||||
* @covers Modules\ItemManagement\Models\NullAttributeValue
|
||||
* @group framework
|
||||
*/
|
||||
public function testId() : void
|
||||
{
|
||||
$null = new NullItemAttributeValue(2);
|
||||
$null = new NullAttributeValue(2);
|
||||
self::assertEquals(2, $null->getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user