From a8c964c6c55ced6dc650bcb636aee11ca67dc63d Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 24 Jun 2021 00:06:49 +0200 Subject: [PATCH] fix l11n call --- Controller/ApiController.php | 13 ++----------- Theme/Backend/sales-item-list.tpl.php | 1 + Theme/Backend/sales-item-profile.tpl.php | 13 ++++++++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 474efd5..eea6b3a 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -277,18 +277,9 @@ final class ApiController extends Controller } $attrType = $this->createItemAttributeTypeFromRequest($request); + $attrType->setL11n($request->getData('title'), $request->getData('language')); $this->createModel($request->header->account, $attrType, ItemAttributeTypeMapper::class, 'attr_type', $request->getOrigin()); - $l11nRequest = new HttpRequest($request->uri); - $l11nRequest->setData('type', $attrType->getId()); - $l11nRequest->setData('title', $request->getData('title')); - $l11nRequest->setData('language', $request->getData('language')); - - $l11nAttributeType = $this->createItemAttributeTypeL11nFromRequest($l11nRequest); - $this->createModel($request->header->account, $l11nAttributeType, ItemAttributeTypeL11nMapper::class, 'attr_type_l11n_create', $request->getOrigin()); - - $attrType->setL11n($l11nAttributeType); - $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Attribute type', 'Attribute type successfully created', $attrType); } @@ -304,7 +295,7 @@ final class ApiController extends Controller private function createItemAttributeTypeFromRequest(RequestAbstract $request) : ItemAttributeType { $attrType = new ItemAttributeType(); - $attrType->setL11n((string) ($request->getData('name') ?? '')); + $attrType->name = (string) ($request->getData('name') ?? ''); $attrType->setFields((int) ($request->getData('fields') ?? 0)); $attrType->setCustom((bool) ($request->getData('custom') ?? false)); diff --git a/Theme/Backend/sales-item-list.tpl.php b/Theme/Backend/sales-item-list.tpl.php index 94b30e9..6efc8ab 100755 --- a/Theme/Backend/sales-item-list.tpl.php +++ b/Theme/Backend/sales-item-list.tpl.php @@ -16,6 +16,7 @@ use Modules\Media\Models\NullMedia; use phpOMS\Uri\UriFactory; /** @var \phpOMS\Views\View $this */ +/** @var \Modules\ItemManagement\Models\Item[] $items */ $items = $this->getData('items'); echo $this->getData('nav')->render(); ?> diff --git a/Theme/Backend/sales-item-profile.tpl.php b/Theme/Backend/sales-item-profile.tpl.php index a268916..af53c29 100755 --- a/Theme/Backend/sales-item-profile.tpl.php +++ b/Theme/Backend/sales-item-profile.tpl.php @@ -18,11 +18,13 @@ use phpOMS\Localization\Money; use phpOMS\Localization\NullLocalization; use phpOMS\Uri\UriFactory; -/** - * @var \Modules\ItemManagement\Models\Item $item - */ -$item = $this->getData('item'); -$itemL11n = $this->getData('itemL11n'); +/** @var \Modules\ItemManagement\Models\Item $item */ +$item = $this->getData('item'); + +/** @var \Modules\ItemManagement\Models\ItemL11n $itemL11n */ +$itemL11n = $this->getData('itemL11n'); + +/** @var \Modules\ItemManagement\Models\ItemAttribute $itemAttribute */ $itemAttribute = $this->getData('itemAttribute'); $notes = $item->getNotes(); @@ -37,6 +39,7 @@ $monthlySalesCosts = $this->getData('monthlySalesCosts') ?? []; $languages = ISO639Enum::getConstants(); +/** @var \phpOMS\Localization\Localization $l11n */ $l11n = $this->getData('defaultlocalization') ?? new NullLocalization(); echo $this->getData('nav')->render();