From 6549ec0323b6ebf7bb513625a3f8dbd2a9d05ebb Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 26 Jan 2024 22:53:59 +0000 Subject: [PATCH] auto fixes + some impl. --- Admin/Installer.php | 5 +- Admin/Routes/Web/Backend.php | 8 +-- Controller/ApiController.php | 15 ++--- Models/LabelLayout.php | 14 ++--- Models/LabelLayoutL11nMapper.php | 8 +-- Models/LabelLayoutMapper.php | 20 +++---- Theme/Backend/Lang/Navigation.de.lang.php | 2 +- Theme/Backend/Lang/Navigation.en.lang.php | 2 +- Theme/Backend/item-list.tpl.php | 34 +++++------ Theme/Backend/layout-list.tpl.php | 20 +++---- tests/Autoloader.php | 4 +- tests/Bootstrap.php | 71 +++++++++++++---------- 12 files changed, 107 insertions(+), 96 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index c1c7e2a..2e979dc 100644 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -20,7 +20,6 @@ use phpOMS\Message\Http\HttpRequest; use phpOMS\Message\Http\HttpResponse; use phpOMS\Module\InstallerAbstract; use phpOMS\Module\ModuleInfo; -use phpOMS\Uri\HttpUri; /** * Installer class. @@ -83,7 +82,7 @@ final class Installer extends InstallerAbstract foreach ($layouts as $layout) { $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('title', \reset($layout['l11n'])); @@ -123,7 +122,7 @@ final class Installer extends InstallerAbstract } $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('title', $l11n); diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 68aa339..669b72a 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -6,7 +6,7 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ - '^.*/warehouse/labeling/item/list.*$' => [ + '^.*/warehouse/labeling/item/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Labeling\Controller\BackendController:viewItemList', 'verb' => RouteVerb::GET, @@ -17,7 +17,7 @@ return [ ], ], ], - '^.*/warehouse/labeling/item\?.*$' => [ + '^.*/warehouse/labeling/item(\?.*$|$)' => [ [ 'dest' => '\Modules\Labeling\Controller\BackendController:viewItem', 'verb' => RouteVerb::GET, @@ -28,7 +28,7 @@ return [ ], ], ], - '^.*/warehouse/labeling/layout\?.*$' => [ + '^.*/warehouse/labeling/layout(\?.*$|$)' => [ [ 'dest' => '\Modules\Labeling\Controller\BackendController:viewLayout', 'verb' => RouteVerb::GET, @@ -39,7 +39,7 @@ return [ ], ], ], - '^.*/warehouse/labeling/layout/list.*$' => [ + '^.*/warehouse/labeling/layout/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Labeling\Controller\BackendController:viewItemLabelList', 'verb' => RouteVerb::GET, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index da6fbab..e87d9ca 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -94,7 +94,10 @@ final class ApiController extends Controller private function createLabelLayoutFromRequest(RequestAbstract $request) : LabelLayout { $labelLayout = new LabelLayout(); - $labelLayout->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $labelLayout->setL11n( + $request->getDataString('title') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); $path = '/Modules/Labeling/Templates/' . $request->getDataString('title'); $uploadedFiles = $request->files; @@ -176,12 +179,10 @@ final class ApiController extends Controller */ private function createLabelLayoutL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $labelLayoutL11n = new BaseStringL11n(); - $labelLayoutL11n->ref = $request->getDataInt('layout') ?? 0; - $labelLayoutL11n->setLanguage( - $request->getDataString('language') ?? $request->header->l11n->language - ); - $labelLayoutL11n->content = $request->getDataString('title') ?? ''; + $labelLayoutL11n = new BaseStringL11n(); + $labelLayoutL11n->ref = $request->getDataInt('layout') ?? 0; + $labelLayoutL11n->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language; + $labelLayoutL11n->content = $request->getDataString('title') ?? ''; return $labelLayoutL11n; } diff --git a/Models/LabelLayout.php b/Models/LabelLayout.php index ef987f6..8b4aa46 100644 --- a/Models/LabelLayout.php +++ b/Models/LabelLayout.php @@ -60,13 +60,13 @@ class LabelLayout implements \JsonSerializable if ($l11n instanceof BaseStringL11n) { $this->l11n = $l11n; } elseif (isset($this->l11n) && $this->l11n instanceof BaseStringL11n) { - $this->l11n->content = $l11n; - $this->l11n->setLanguage($lang); + $this->l11n->content = $l11n; + $this->l11n->language = $lang; } else { - $this->l11n = new BaseStringL11n(); - $this->l11n->content = $l11n; - $this->l11n->ref = $this->id; - $this->l11n->setLanguage($lang); + $this->l11n = new BaseStringL11n(); + $this->l11n->content = $l11n; + $this->l11n->ref = $this->id; + $this->l11n->language = $lang; } } @@ -90,7 +90,7 @@ class LabelLayout implements \JsonSerializable public function toArray() : array { return [ - 'id' => $this->id, + 'id' => $this->id, ]; } diff --git a/Models/LabelLayoutL11nMapper.php b/Models/LabelLayoutL11nMapper.php index 6d93398..3495603 100644 --- a/Models/LabelLayoutL11nMapper.php +++ b/Models/LabelLayoutL11nMapper.php @@ -37,10 +37,10 @@ final class LabelLayoutL11nMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'labeling_layout_l11n_id' => ['name' => 'labeling_layout_l11n_id', 'type' => 'int', 'internal' => 'id'], - 'labeling_layout_l11n_name' => ['name' => 'labeling_layout_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], - 'labeling_layout_l11n_type' => ['name' => 'labeling_layout_l11n_type', 'type' => 'int', 'internal' => 'ref'], - 'labeling_layout_l11n_language' => ['name' => 'labeling_layout_l11n_language', 'type' => 'string', 'internal' => 'language'], + 'labeling_layout_l11n_id' => ['name' => 'labeling_layout_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'labeling_layout_l11n_name' => ['name' => 'labeling_layout_l11n_name', 'type' => 'string', 'internal' => 'content', 'autocomplete' => true], + 'labeling_layout_l11n_type' => ['name' => 'labeling_layout_l11n_type', 'type' => 'int', 'internal' => 'ref'], + 'labeling_layout_l11n_language' => ['name' => 'labeling_layout_l11n_language', 'type' => 'string', 'internal' => 'language'], ]; /** diff --git a/Models/LabelLayoutMapper.php b/Models/LabelLayoutMapper.php index e38638a..8fb29a0 100644 --- a/Models/LabelLayoutMapper.php +++ b/Models/LabelLayoutMapper.php @@ -37,8 +37,8 @@ final class LabelLayoutMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'labeling_layout_id' => ['name' => 'labeling_layout_id', 'type' => 'int', 'internal' => 'id'], - 'labeling_layout_template' => ['name' => 'labeling_layout_template', 'type' => 'int', 'internal' => 'template'], + 'labeling_layout_id' => ['name' => 'labeling_layout_id', 'type' => 'int', 'internal' => 'id'], + 'labeling_layout_template' => ['name' => 'labeling_layout_template', 'type' => 'int', 'internal' => 'template'], ]; /** @@ -49,11 +49,11 @@ final class LabelLayoutMapper extends DataMapperFactory */ public const HAS_MANY = [ 'l11n' => [ - 'mapper' => LabelLayoutL11nMapper::class, - 'table' => 'labeling_layout_l11n', - 'self' => 'labeling_layout_l11n_type', - 'column' => 'content', - 'external' => null, + 'mapper' => LabelLayoutL11nMapper::class, + 'table' => 'labeling_layout_l11n', + 'self' => 'labeling_layout_l11n_type', + 'column' => 'content', + 'external' => null, ], ]; @@ -64,9 +64,9 @@ final class LabelLayoutMapper extends DataMapperFactory * @since 1.0.0 */ public const OWNS_ONE = [ - 'template' => [ - 'mapper' => CollectionMapper::class, - 'external' => 'labeling_layout_template', + 'template' => [ + 'mapper' => CollectionMapper::class, + 'external' => 'labeling_layout_template', ], ]; diff --git a/Theme/Backend/Lang/Navigation.de.lang.php b/Theme/Backend/Lang/Navigation.de.lang.php index 9e3382a..437d82d 100644 --- a/Theme/Backend/Lang/Navigation.de.lang.php +++ b/Theme/Backend/Lang/Navigation.de.lang.php @@ -15,6 +15,6 @@ declare(strict_types=1); return ['Navigation' => [ 'Labeling' => 'Etikettierung', 'List' => 'Liste', - 'Layouts' => 'Designs', + 'Layouts' => 'Designs', 'Name' => 'Name', ]]; diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php index 4424c3e..ed38f5c 100644 --- a/Theme/Backend/Lang/Navigation.en.lang.php +++ b/Theme/Backend/Lang/Navigation.en.lang.php @@ -15,6 +15,6 @@ declare(strict_types=1); return ['Navigation' => [ 'Labeling' => 'Labeling', 'List' => 'List', - 'Layouts' => 'Layouts', + 'Layouts' => 'Layouts', 'Name' => 'Name', ]]; diff --git a/Theme/Backend/item-list.tpl.php b/Theme/Backend/item-list.tpl.php index 5029af2..d50209b 100644 --- a/Theme/Backend/item-list.tpl.php +++ b/Theme/Backend/item-list.tpl.php @@ -25,53 +25,53 @@ echo $this->data['nav']->render(); ?>
getHtml('Items', 'ItemManagement', 'Backend'); ?>download
- +
getHtml('Number', 'ItemManagement', 'Backend'); ?> - getHtml('Name', 'ItemManagement', 'Backend'); ?> - getHtml('Name', 'ItemManagement', 'Backend'); ?> - getHtml('Name', 'ItemManagement', 'Backend'); ?> -