mirror of
https://github.com/Karaka-Management/oms-Organization.git
synced 2026-01-26 14:48:40 +00:00
update
This commit is contained in:
parent
eda8d98c46
commit
ba07fd51a1
19
Admin/Install/attributes.json → Admin/Install/address_attributes.json
Executable file → Normal file
19
Admin/Install/attributes.json → Admin/Install/address_attributes.json
Executable file → Normal file
|
|
@ -26,10 +26,10 @@
|
|||
"values": []
|
||||
},
|
||||
{
|
||||
"name": "legal_form",
|
||||
"name": "tax_office",
|
||||
"l11n": {
|
||||
"en": "Legal form",
|
||||
"de": "Rechtsform"
|
||||
"en": "Tax office",
|
||||
"de": "Finanzamt"
|
||||
},
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": true,
|
||||
|
|
@ -50,5 +50,18 @@
|
|||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": []
|
||||
},
|
||||
{
|
||||
"name": "registration_office",
|
||||
"l11n": {
|
||||
"en": "Registration office",
|
||||
"de": "Registergericht"
|
||||
},
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": true,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": []
|
||||
}
|
||||
]
|
||||
28
Admin/Install/unit_attributes.json
Normal file
28
Admin/Install/unit_attributes.json
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[
|
||||
{
|
||||
"name": "legal_form",
|
||||
"l11n": {
|
||||
"en": "Legal form",
|
||||
"de": "Rechtsform"
|
||||
},
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": true,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": []
|
||||
},
|
||||
{
|
||||
"name": "legal_representative",
|
||||
"l11n": {
|
||||
"en": "Legal representatice",
|
||||
"de": "Gesetzlicher Vertreter"
|
||||
},
|
||||
"value_type": 2,
|
||||
"is_custom_allowed": true,
|
||||
"validation_pattern": "",
|
||||
"is_required": false,
|
||||
"default_value": "",
|
||||
"values": []
|
||||
}
|
||||
]
|
||||
|
|
@ -51,8 +51,8 @@ final class Installer extends InstallerAbstract
|
|||
|
||||
self::installDefaultUnit();
|
||||
|
||||
/* Attributes */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/attributes.json');
|
||||
/* Unit Attributes */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/unit_attributes.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -64,6 +64,20 @@ final class Installer extends InstallerAbstract
|
|||
|
||||
$attrTypes = self::createUnitAttributeTypes($app, $attributes);
|
||||
$attrValues = self::createUnitAttributeValues($app, $attrTypes, $attributes);
|
||||
|
||||
/* Address Attributes */
|
||||
$fileContent = \file_get_contents(__DIR__ . '/Install/address_attributes.json');
|
||||
if ($fileContent === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attributes = \json_decode($fileContent, true);
|
||||
if (!\is_array($attributes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$attrTypes = self::createAddressAttributeTypes($app, $attributes);
|
||||
$attrValues = self::createAddressAttributeValues($app, $attrTypes, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -206,6 +220,146 @@ final class Installer extends InstallerAbstract
|
|||
return $unitAttrValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install default attribute types
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $attributes Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createAddressAttributeTypes(ApplicationAbstract $app, array $attributes) : array
|
||||
{
|
||||
/** @var array<string, array> $addressAttrType */
|
||||
$addressAttrType = [];
|
||||
|
||||
/** @var \Modules\Organization\Controller\ApiAddressAttributeController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('Organization', 'ApiAddressAttribute');
|
||||
|
||||
/** @var array $attribute */
|
||||
foreach ($attributes as $attribute) {
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('name', $attribute['name'] ?? '');
|
||||
$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('custom', $attribute['is_custom_allowed'] ?? false);
|
||||
$request->setData('validation_pattern', $attribute['validation_pattern'] ?? '');
|
||||
$request->setData('datatype', (int) $attribute['value_type']);
|
||||
|
||||
$module->apiAddressAttributeTypeCreate($request, $response);
|
||||
|
||||
$responseData = $response->get('');
|
||||
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$addressAttrType[$attribute['name']] = !\is_array($responseData['response'])
|
||||
? $responseData['response']->toArray()
|
||||
: $responseData['response'];
|
||||
|
||||
$isFirst = true;
|
||||
foreach ($attribute['l11n'] as $language => $l11n) {
|
||||
if ($isFirst) {
|
||||
$isFirst = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n);
|
||||
$request->setData('language', $language);
|
||||
$request->setData('type', $addressAttrType[$attribute['name']]['id']);
|
||||
|
||||
$module->apiAddressAttributeTypeL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
|
||||
return $addressAttrType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create default attribute values for types
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $addressAttrType Attribute types
|
||||
* @param array $attributes Attribute definition
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static function createAddressAttributeValues(ApplicationAbstract $app, array $addressAttrType, array $attributes) : array
|
||||
{
|
||||
/** @var array<string, array> $addressAttrValue */
|
||||
$addressAttrValue = [];
|
||||
|
||||
/** @var \Modules\Organization\Controller\ApiAddressAttributeController $module */
|
||||
$module = $app->moduleManager->getModuleInstance('Organization', 'ApiAddressAttribute');
|
||||
|
||||
foreach ($attributes as $attribute) {
|
||||
$addressAttrValue[$attribute['name']] = [];
|
||||
|
||||
/** @var array $value */
|
||||
foreach ($attribute['values'] as $value) {
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('value', $value['value'] ?? '');
|
||||
$request->setData('unit', $value['unit'] ?? '');
|
||||
$request->setData('default', true); // always true since all defined values are possible default values
|
||||
$request->setData('type', $addressAttrType[$attribute['name']]['id']);
|
||||
|
||||
if (isset($value['l11n']) && !empty($value['l11n'])) {
|
||||
$request->setData('title', \reset($value['l11n']));
|
||||
$request->setData('language', \array_keys($value['l11n'])[0] ?? 'en');
|
||||
}
|
||||
|
||||
$module->apiAddressAttributeValueCreate($request, $response);
|
||||
|
||||
$responseData = $response->get('');
|
||||
if (!\is_array($responseData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$attrValue = !\is_array($responseData['response'])
|
||||
? $responseData['response']->toArray()
|
||||
: $responseData['response'];
|
||||
|
||||
$addressAttrValue[$attribute['name']][] = $attrValue;
|
||||
|
||||
$isFirst = true;
|
||||
foreach (($value['l11n'] ?? []) as $language => $l11n) {
|
||||
if ($isFirst) {
|
||||
$isFirst = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
$response = new HttpResponse();
|
||||
$request = new HttpRequest(new HttpUri(''));
|
||||
|
||||
$request->header->account = 1;
|
||||
$request->setData('title', $l11n);
|
||||
$request->setData('language', $language);
|
||||
$request->setData('value', $attrValue['id']);
|
||||
|
||||
$module->apiAddressAttributeValueL11nCreate($request, $response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $addressAttrValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install default unit
|
||||
*
|
||||
|
|
|
|||
522
Controller/ApiAddressAttributeController.php
Normal file
522
Controller/ApiAddressAttributeController.php
Normal file
|
|
@ -0,0 +1,522 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Organization
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Organization\Controller;
|
||||
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use Modules\Organization\Models\Attribute\AddressAttributeMapper;
|
||||
use Modules\Organization\Models\Attribute\AddressAttributeTypeL11nMapper;
|
||||
use Modules\Organization\Models\Attribute\AddressAttributeTypeMapper;
|
||||
use Modules\Organization\Models\Attribute\AddressAttributeValueL11nMapper;
|
||||
use Modules\Organization\Models\Attribute\AddressAttributeValueMapper;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
use phpOMS\Message\Http\RequestStatusCode;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
|
||||
/**
|
||||
* Organization class.
|
||||
*
|
||||
* @package Modules\Organization
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*/
|
||||
final class ApiAddressAttributeController extends Controller
|
||||
{
|
||||
use \Modules\Attribute\Controller\ApiAttributeTraitController;
|
||||
|
||||
/**
|
||||
* Api method to create address attribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attribute = $this->createAttributeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attribute, AddressAttributeMapper::class, 'attribute', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create address attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeTypeL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createAttributeTypeL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, AddressAttributeTypeL11nMapper::class, 'attr_type_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create address attribute type
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeTypeCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrType = $this->createAttributeTypeFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrType, AddressAttributeTypeMapper::class, 'attr_type', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create address attribute value
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeValueCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\Attribute\Models\AttributeType $type */
|
||||
$type = AddressAttributeTypeMapper::get()
|
||||
->where('id', $request->getDataInt('type') ?? 0)
|
||||
->execute();
|
||||
|
||||
$attrValue = $this->createAttributeValueFromRequest($request, $type);
|
||||
$this->createModel($request->header->account, $attrValue, AddressAttributeValueMapper::class, 'attr_value', $request->getOrigin());
|
||||
|
||||
if ($attrValue->isDefault) {
|
||||
$this->createModelRelation(
|
||||
$request->header->account,
|
||||
(int) $request->getData('type'),
|
||||
$attrValue->id,
|
||||
AddressAttributeTypeMapper::class, 'defaults', '', $request->getOrigin()
|
||||
);
|
||||
}
|
||||
|
||||
$this->createStandardCreateResponse($request, $response, $attrValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to create address attribute l11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeValueL11nCreate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueL11nCreate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidCreateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$attrL11n = $this->createAttributeValueL11nFromRequest($request);
|
||||
$this->createModel($request->header->account, $attrL11n, AddressAttributeValueL11nMapper::class, 'attr_value_l11n', $request->getOrigin());
|
||||
$this->createStandardCreateResponse($request, $response, $attrL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AddressAttribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Attribute $old */
|
||||
$old = AddressAttributeMapper::get()
|
||||
->with('type')
|
||||
->with('type/defaults')
|
||||
->with('value')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
$new = $this->updateAttributeFromRequest($request, clone $old);
|
||||
|
||||
if ($new->id === 0) {
|
||||
// Set response header to invalid request because of invalid data
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $new);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AddressAttributeMapper::class, 'address_attribute', $request->getOrigin());
|
||||
|
||||
if ($new->value->getValue() !== $old->value->getValue()) {
|
||||
$this->updateModel($request->header->account, $old->value, $new->value, AddressAttributeValueMapper::class, 'attribute_value', $request->getOrigin());
|
||||
}
|
||||
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AddressAttribute
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeDelete(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$addressAttribute = AddressAttributeMapper::get()
|
||||
->with('type')
|
||||
->where('id', (int) $request->getData('id'))
|
||||
->execute();
|
||||
|
||||
if ($addressAttribute->type->isRequired) {
|
||||
$this->createInvalidDeleteResponse($request, $response, []);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->deleteModel($request->header->account, $addressAttribute, AddressAttributeMapper::class, 'address_attribute', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $addressAttribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AddressAttributeTypeL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeTypeL11nUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeL11nUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $old */
|
||||
$old = AddressAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$new = $this->updateAttributeTypeL11nFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AddressAttributeTypeL11nMapper::class, 'address_attribute_type_l11n', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AddressAttributeTypeL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeTypeL11nDelete(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeL11nDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $addressAttributeTypeL11n */
|
||||
$addressAttributeTypeL11n = AddressAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $addressAttributeTypeL11n, AddressAttributeTypeL11nMapper::class, 'address_attribute_type_l11n', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $addressAttributeTypeL11n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AddressAttributeType
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeTypeUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var AttributeType $old */
|
||||
$old = AddressAttributeTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$new = $this->updateAttributeTypeFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AddressAttributeTypeMapper::class, 'address_attribute_type', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AddressAttributeType
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @todo: implement
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeTypeDelete(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeTypeDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var AttributeType $addressAttributeType */
|
||||
$addressAttributeType = AddressAttributeTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $addressAttributeType, AddressAttributeTypeMapper::class, 'address_attribute_type', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $addressAttributeType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AddressAttributeValue
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeValueUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var AttributeValue $old */
|
||||
$old = AddressAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
|
||||
/** @var \Modules\Attribute\Models\Attribute $attr */
|
||||
$attr = AddressAttributeMapper::get()
|
||||
->with('type')
|
||||
->where('id', $request->getDataInt('attribute') ?? 0)
|
||||
->execute();
|
||||
|
||||
$new = $this->updateAttributeValueFromRequest($request, clone $old, $attr);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AddressAttributeValueMapper::class, 'address_attribute_value', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AddressAttributeValue
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeValueDelete(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
return;
|
||||
// @todo: I don't think values can be deleted? Only Attributes
|
||||
// However, It should be possible to remove UNUSED default values
|
||||
// either here or other function?
|
||||
if (!empty($val = $this->validateAttributeValueDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\Organization\Models\AddressAttributeValue $addressAttributeValue */
|
||||
$addressAttributeValue = AddressAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $addressAttributeValue, AddressAttributeValueMapper::class, 'address_attribute_value', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $addressAttributeValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to update AddressAttributeValueL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeValueL11nUpdate(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueL11nUpdate($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidUpdateResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $old */
|
||||
$old = AddressAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'));
|
||||
$new = $this->updateAttributeValueL11nFromRequest($request, clone $old);
|
||||
|
||||
$this->updateModel($request->header->account, $old, $new, AddressAttributeValueL11nMapper::class, 'address_attribute_value_l11n', $request->getOrigin());
|
||||
$this->createStandardUpdateResponse($request, $response, $new);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to delete AddressAttributeValueL11n
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function apiAddressAttributeValueL11nDelete(RequestAbstract $request, ResponseAbstract $response, mixed $data = null) : void
|
||||
{
|
||||
if (!empty($val = $this->validateAttributeValueL11nDelete($request))) {
|
||||
$response->header->status = RequestStatusCode::R_400;
|
||||
$this->createInvalidDeleteResponse($request, $response, $val);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var BaseStringL11n $addressAttributeValueL11n */
|
||||
$addressAttributeValueL11n = AddressAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $addressAttributeValueL11n, AddressAttributeValueL11nMapper::class, 'address_attribute_value_l11n', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $addressAttributeValueL11n);
|
||||
}
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ final class ApiAttributeController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\Organization\Models\UnitAttributeTypeL11n $unitAttributeTypeL11n */
|
||||
/** @var BaseStringL11n $unitAttributeTypeL11n */
|
||||
$unitAttributeTypeL11n = UnitAttributeTypeL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $unitAttributeTypeL11n, UnitAttributeTypeL11nMapper::class, 'unit_attribute_type_l11n', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $unitAttributeTypeL11n);
|
||||
|
|
@ -387,7 +387,7 @@ final class ApiAttributeController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\Organization\Models\UnitAttributeType $unitAttributeType */
|
||||
/** @var AttributeType $unitAttributeType */
|
||||
$unitAttributeType = UnitAttributeTypeMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $unitAttributeType, UnitAttributeTypeMapper::class, 'unit_attribute_type', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $unitAttributeType);
|
||||
|
|
@ -418,7 +418,7 @@ final class ApiAttributeController extends Controller
|
|||
/** @var AttributeValue $old */
|
||||
$old = UnitAttributeValueMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
|
||||
/** @var \Modules\Attribute\Models\Attribute $type */
|
||||
/** @var \Modules\Attribute\Models\Attribute $attr */
|
||||
$attr = UnitAttributeMapper::get()
|
||||
->with('type')
|
||||
->where('id', $request->getDataInt('attribute') ?? 0)
|
||||
|
|
@ -514,7 +514,7 @@ final class ApiAttributeController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
/** @var \Modules\Organization\Models\UnitAttributeValueL11n $unitAttributeValueL11n */
|
||||
/** @var BaseStringL11n $unitAttributeValueL11n */
|
||||
$unitAttributeValueL11n = UnitAttributeValueL11nMapper::get()->where('id', (int) $request->getData('id'))->execute();
|
||||
$this->deleteModel($request->header->account, $unitAttributeValueL11n, UnitAttributeValueL11nMapper::class, 'unit_attribute_value_l11n', $request->getOrigin());
|
||||
$this->createStandardDeleteResponse($request, $response, $unitAttributeValueL11n);
|
||||
|
|
|
|||
86
Models/Attribute/AddressAttributeMapper.php
Normal file
86
Models/Attribute/AddressAttributeMapper.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Organization\Models\Attribute;
|
||||
|
||||
use Modules\Attribute\Models\Attribute;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Address mapper class.
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of Attribute
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AddressAttributeMapper 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 = [
|
||||
'address_attr_id' => ['name' => 'address_attr_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'address_attr_address' => ['name' => 'address_attr_address', 'type' => 'int', 'internal' => 'ref'],
|
||||
'address_attr_type' => ['name' => 'address_attr_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'address_attr_value' => ['name' => 'address_attr_value', 'type' => 'int', 'internal' => 'value'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
'type' => [
|
||||
'mapper' => AddressAttributeTypeMapper::class,
|
||||
'external' => 'address_attr_type',
|
||||
],
|
||||
'value' => [
|
||||
'mapper' => AddressAttributeValueMapper::class,
|
||||
'external' => 'address_attr_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = Attribute::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'address_attr';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'address_attr_id';
|
||||
}
|
||||
69
Models/Attribute/AddressAttributeTypeL11nMapper.php
Normal file
69
Models/Attribute/AddressAttributeTypeL11nMapper.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Organization\Models\Attribute;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Address mapper class.
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AddressAttributeTypeL11nMapper 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 = [
|
||||
'address_attr_type_l11n_id' => ['name' => 'address_attr_type_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'address_attr_type_l11n_title' => ['name' => 'address_attr_type_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'address_attr_type_l11n_type' => ['name' => 'address_attr_type_l11n_type', 'type' => 'int', 'internal' => 'ref'],
|
||||
'address_attr_type_l11n_lang' => ['name' => 'address_attr_type_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'address_attr_type_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'address_attr_type_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
94
Models/Attribute/AddressAttributeTypeMapper.php
Normal file
94
Models/Attribute/AddressAttributeTypeMapper.php
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Organization\Models\Attribute;
|
||||
|
||||
use Modules\Attribute\Models\AttributeType;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Address mapper class.
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of AttributeType
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AddressAttributeTypeMapper 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 = [
|
||||
'address_attr_type_id' => ['name' => 'address_attr_type_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'address_attr_type_name' => ['name' => 'address_attr_type_name', 'type' => 'string', 'internal' => 'name', 'autocomplete' => true],
|
||||
'address_attr_type_datatype' => ['name' => 'address_attr_type_datatype', 'type' => 'int', 'internal' => 'datatype'],
|
||||
'address_attr_type_fields' => ['name' => 'address_attr_type_fields', 'type' => 'int', 'internal' => 'fields'],
|
||||
'address_attr_type_custom' => ['name' => 'address_attr_type_custom', 'type' => 'bool', 'internal' => 'custom'],
|
||||
'address_attr_type_pattern' => ['name' => 'address_attr_type_pattern', 'type' => 'string', 'internal' => 'validationPattern'],
|
||||
'address_attr_type_required' => ['name' => 'address_attr_type_required', 'type' => 'bool', 'internal' => 'isRequired'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => AddressAttributeTypeL11nMapper::class,
|
||||
'table' => 'address_attr_type_l11n',
|
||||
'self' => 'address_attr_type_l11n_type',
|
||||
'column' => 'content',
|
||||
'external' => null,
|
||||
],
|
||||
'defaults' => [
|
||||
'mapper' => AddressAttributeValueMapper::class,
|
||||
'table' => 'address_attr_default',
|
||||
'self' => 'address_attr_default_type',
|
||||
'external' => 'address_attr_default_value',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = AttributeType::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'address_attr_type';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'address_attr_type_id';
|
||||
}
|
||||
69
Models/Attribute/AddressAttributeValueL11nMapper.php
Normal file
69
Models/Attribute/AddressAttributeValueL11nMapper.php
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Organization\Models\Attribute;
|
||||
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
use phpOMS\Localization\BaseStringL11n;
|
||||
|
||||
/**
|
||||
* Address mapper class.
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of BaseStringL11n
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AddressAttributeValueL11nMapper 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 = [
|
||||
'address_attr_value_l11n_id' => ['name' => 'address_attr_value_l11n_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'address_attr_value_l11n_title' => ['name' => 'address_attr_value_l11n_title', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true],
|
||||
'address_attr_value_l11n_value' => ['name' => 'address_attr_value_l11n_value', 'type' => 'int', 'internal' => 'ref'],
|
||||
'address_attr_value_l11n_lang' => ['name' => 'address_attr_value_l11n_lang', 'type' => 'string', 'internal' => 'language'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'address_attr_value_l11n';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'address_attr_value_l11n_id';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = BaseStringL11n::class;
|
||||
}
|
||||
89
Models/Attribute/AddressAttributeValueMapper.php
Normal file
89
Models/Attribute/AddressAttributeValueMapper.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* Jingga
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 2.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Organization\Models\Attribute;
|
||||
|
||||
use Modules\Attribute\Models\AttributeValue;
|
||||
use phpOMS\DataStorage\Database\Mapper\DataMapperFactory;
|
||||
|
||||
/**
|
||||
* Address mapper class.
|
||||
*
|
||||
* @package Modules\Organization\Models\Attribute
|
||||
* @license OMS License 2.0
|
||||
* @link https://jingga.app
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @template T of AttributeValue
|
||||
* @extends DataMapperFactory<T>
|
||||
*/
|
||||
final class AddressAttributeValueMapper 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 = [
|
||||
'address_attr_value_id' => ['name' => 'address_attr_value_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'address_attr_value_default' => ['name' => 'address_attr_value_default', 'type' => 'bool', 'internal' => 'isDefault'],
|
||||
'address_attr_value_valueStr' => ['name' => 'address_attr_value_valueStr', 'type' => 'string', 'internal' => 'valueStr'],
|
||||
'address_attr_value_valueInt' => ['name' => 'address_attr_value_valueInt', 'type' => 'int', 'internal' => 'valueInt'],
|
||||
'address_attr_value_valueDec' => ['name' => 'address_attr_value_valueDec', 'type' => 'float', 'internal' => 'valueDec'],
|
||||
'address_attr_value_valueDat' => ['name' => 'address_attr_value_valueDat', 'type' => 'DateTime', 'internal' => 'valueDat'],
|
||||
'address_attr_value_unit' => ['name' => 'address_attr_value_unit', 'type' => 'string', 'internal' => 'unit'],
|
||||
'address_attr_value_deptype' => ['name' => 'address_attr_value_deptype', 'type' => 'int', 'internal' => 'dependingAttributeType'],
|
||||
'address_attr_value_depvalue' => ['name' => 'address_attr_value_depvalue', 'type' => 'int', 'internal' => 'dependingAttributeValue'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
'l11n' => [
|
||||
'mapper' => AddressAttributeValueL11nMapper::class,
|
||||
'table' => 'address_attr_value_l11n',
|
||||
'self' => 'address_attr_value_l11n_value',
|
||||
'external' => null,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
* @var class-string<T>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const MODEL = AttributeValue::class;
|
||||
|
||||
/**
|
||||
* Primary table.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const TABLE = 'address_attr_value';
|
||||
|
||||
/**
|
||||
* Primary field name.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const PRIMARYFIELD = 'address_attr_value_id';
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user