From 993b0666388c94565b2b82c68bf3daa6688351f4 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 9 May 2023 16:07:43 +0000 Subject: [PATCH] fixes --- Controller/ApiController.php | 24 +++--- Models/Client.php | 1 - Models/ClientL11n.php | 143 -------------------------------- Models/ClientL11nMapper.php | 15 +++- Models/ClientL11nType.php | 93 --------------------- Models/ClientL11nTypeMapper.php | 11 ++- Models/NullClientL11n.php | 47 ----------- Models/NullClientL11nType.php | 46 ---------- 8 files changed, 33 insertions(+), 347 deletions(-) delete mode 100755 Models/ClientL11n.php delete mode 100755 Models/ClientL11nType.php delete mode 100755 Models/NullClientL11n.php delete mode 100755 Models/NullClientL11nType.php diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 7040be4..742abd0 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -31,21 +31,19 @@ use Modules\ClientManagement\Models\ClientAttributeTypeL11nMapper; use Modules\ClientManagement\Models\ClientAttributeTypeMapper; use Modules\ClientManagement\Models\ClientAttributeValueL11nMapper; use Modules\ClientManagement\Models\ClientAttributeValueMapper; -use Modules\ClientManagement\Models\ClientL11n; use Modules\ClientManagement\Models\ClientL11nMapper; -use Modules\ClientManagement\Models\ClientL11nType; use Modules\ClientManagement\Models\ClientL11nTypeMapper; use Modules\ClientManagement\Models\ClientMapper; -use Modules\ClientManagement\Models\NullClient; -use Modules\ClientManagement\Models\NullClientL11nType; use Modules\Media\Models\MediaMapper; use Modules\Media\Models\PathSettings; use Modules\Organization\Models\UnitMapper; use phpOMS\Api\EUVAT\EUVATVies; use phpOMS\Localization\BaseStringL11n; +use phpOMS\Localization\BaseStringL11nType; use phpOMS\Localization\ISO3166CharEnum; use phpOMS\Localization\ISO3166TwoEnum; use phpOMS\Localization\ISO639x1Enum; +use phpOMS\Localization\NullBaseStringL11nType; use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Message\Http\RequestStatusCode; @@ -385,19 +383,19 @@ final class ApiController extends Controller * * @param RequestAbstract $request Request * - * @return ClientL11n + * @return BaseStringL11n * * @since 1.0.0 */ - private function createClientL11nFromRequest(RequestAbstract $request) : ClientL11n + private function createClientL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $clientL11n = new ClientL11n(); - $clientL11n->client = $request->getDataInt('client') ?? 0; - $clientL11n->type = new NullClientL11nType($request->getDataInt('type') ?? 0); + $clientL11n = new BaseStringL11n(); + $clientL11n->ref = $request->getDataInt('client') ?? 0; + $clientL11n->type = new NullBaseStringL11nType($request->getDataInt('type') ?? 0); $clientL11n->setLanguage( $request->getDataString('language') ?? $request->getLanguage() ); - $clientL11n->description = $request->getDataString('description') ?? ''; + $clientL11n->content = $request->getDataString('description') ?? ''; return $clientL11n; } @@ -456,13 +454,13 @@ final class ApiController extends Controller * * @param RequestAbstract $request Request * - * @return ClientL11nType + * @return BaseStringL11nType * * @since 1.0.0 */ - private function createClientL11nTypeFromRequest(RequestAbstract $request) : ClientL11nType + private function createClientL11nTypeFromRequest(RequestAbstract $request) : BaseStringL11nType { - $clientL11nType = new ClientL11nType(); + $clientL11nType = new BaseStringL11nType(); $clientL11nType->title = $request->getDataString('title') ?? ''; $clientL11nType->isRequired = (bool) ($request->getData('is_required') ?? false); diff --git a/Models/Client.php b/Models/Client.php index 79fc835..0184a36 100755 --- a/Models/Client.php +++ b/Models/Client.php @@ -18,7 +18,6 @@ use Modules\Admin\Models\Account; use Modules\Admin\Models\Address; use Modules\Admin\Models\NullAddress; use Modules\Editor\Models\EditorDoc; -use Modules\Media\Models\Media; use Modules\Payment\Models\Payment; use Modules\Profile\Models\ContactElement; use Modules\Profile\Models\NullContactElement; diff --git a/Models/ClientL11n.php b/Models/ClientL11n.php deleted file mode 100755 index 0e7d0e7..0000000 --- a/Models/ClientL11n.php +++ /dev/null @@ -1,143 +0,0 @@ -type = $type ?? new ClientL11nType(); - $this->description = $description; - $this->language = $language; - } - - /** - * Get id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - - /** - * Get language - * - * @return string - * - * @since 1.0.0 - */ - public function getLanguage() : string - { - return $this->language; - } - - /** - * Set language - * - * @param string $language Language - * - * @return void - * - * @since 1.0.0 - */ - public function setLanguage(string $language) : void - { - $this->language = $language; - } - - /** - * {@inheritdoc} - */ - public function toArray() : array - { - return [ - 'id' => $this->id, - 'description' => $this->description, - 'client' => $this->client, - 'language' => $this->language, - ]; - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return $this->toArray(); - } -} diff --git a/Models/ClientL11nMapper.php b/Models/ClientL11nMapper.php index a5a119a..e6d297e 100755 --- a/Models/ClientL11nMapper.php +++ b/Models/ClientL11nMapper.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\ClientManagement\Models; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; +use phpOMS\Localization\BaseStringL11n; /** * Client mapper class. @@ -24,7 +25,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @link https://jingga.app * @since 1.0.0 * - * @template T of ClientL11n + * @template T of BaseStringL11n * @extends DataMapperFactory */ final class ClientL11nMapper extends DataMapperFactory @@ -37,8 +38,8 @@ final class ClientL11nMapper extends DataMapperFactory */ public const COLUMNS = [ 'clientmgmt_client_l11n_id' => ['name' => 'clientmgmt_client_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'clientmgmt_client_l11n_description' => ['name' => 'clientmgmt_client_l11n_description', 'type' => 'string', 'internal' => 'description', 'autocomplete' => true], - 'clientmgmt_client_l11n_client' => ['name' => 'clientmgmt_client_l11n_client', 'type' => 'int', 'internal' => 'client'], + 'clientmgmt_client_l11n_description' => ['name' => 'clientmgmt_client_l11n_description', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'clientmgmt_client_l11n_client' => ['name' => 'clientmgmt_client_l11n_client', 'type' => 'int', 'internal' => 'ref'], 'clientmgmt_client_l11n_lang' => ['name' => 'clientmgmt_client_l11n_lang', 'type' => 'string', 'internal' => 'language'], 'clientmgmt_client_l11n_typeref' => ['name' => 'clientmgmt_client_l11n_typeref', 'type' => 'int', 'internal' => 'type'], ]; @@ -71,4 +72,12 @@ final class ClientL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const PRIMARYFIELD = 'clientmgmt_client_l11n_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11n::class; } diff --git a/Models/ClientL11nType.php b/Models/ClientL11nType.php deleted file mode 100755 index 4b21d6d..0000000 --- a/Models/ClientL11nType.php +++ /dev/null @@ -1,93 +0,0 @@ -title = $title; - } - - /** - * Get id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function toArray() : array - { - return [ - 'id' => $this->id, - 'title' => $this->title, - ]; - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return $this->toArray(); - } -} diff --git a/Models/ClientL11nTypeMapper.php b/Models/ClientL11nTypeMapper.php index a489445..995f94a 100755 --- a/Models/ClientL11nTypeMapper.php +++ b/Models/ClientL11nTypeMapper.php @@ -15,6 +15,7 @@ declare(strict_types=1); namespace Modules\ClientManagement\Models; use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; +use phpOMS\Localization\BaseStringL11nType; /** * Client mapper class. @@ -24,7 +25,7 @@ use phpOMS\DataStorage\Database\Mapper\DataMapperFactory; * @link https://jingga.app * @since 1.0.0 * - * @template T of ClientL11nType + * @template T of BaseStringL11nType * @extends DataMapperFactory */ final class ClientL11nTypeMapper extends DataMapperFactory @@ -56,4 +57,12 @@ final class ClientL11nTypeMapper extends DataMapperFactory * @since 1.0.0 */ public const PRIMARYFIELD = 'clientmgmt_client_l11n_type_id'; + + /** + * Model to use by the mapper. + * + * @var class-string + * @since 1.0.0 + */ + public const MODEL = BaseStringL11nType::class; } diff --git a/Models/NullClientL11n.php b/Models/NullClientL11n.php deleted file mode 100755 index 575f654..0000000 --- a/Models/NullClientL11n.php +++ /dev/null @@ -1,47 +0,0 @@ -id = $id; - parent::__construct(); - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return ['id' => $this->id]; - } -} diff --git a/Models/NullClientL11nType.php b/Models/NullClientL11nType.php deleted file mode 100755 index a243201..0000000 --- a/Models/NullClientL11nType.php +++ /dev/null @@ -1,46 +0,0 @@ -id = $id; - } - - /** - * {@inheritdoc} - */ - public function jsonSerialize() : mixed - { - return ['id' => $this->id]; - } -}