From 21e6d764ccba787e9ffc8af0d4f726eb5b0cf5a9 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Sat, 16 Nov 2024 17:45:20 +0100 Subject: [PATCH] [Changed] improved dynamization of the code --- .../Controller/Admin/ManufacturerInfoLongdesc.php | 12 +++++++----- Modules/Application/Model/D3ManufacturerLongDesc.php | 8 ++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Application/Controller/Admin/ManufacturerInfoLongdesc.php b/Application/Controller/Admin/ManufacturerInfoLongdesc.php index 11e28c1..30d2e2e 100644 --- a/Application/Controller/Admin/ManufacturerInfoLongdesc.php +++ b/Application/Controller/Admin/ManufacturerInfoLongdesc.php @@ -19,6 +19,7 @@ class ManufacturerInfoLongdesc extends AdminDetailsController { parent::render(); + /** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */ $this->_aViewData['edit'] = $oManufacturer = oxNew(\OxidEsales\Eshop\Application\Model\Manufacturer::class); $sOXID = $this->_aViewData["oxid"] = $this->getEditObjectId(); @@ -47,7 +48,7 @@ class ManufacturerInfoLongdesc extends AdminDetailsController } } - $this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, "oxmanufacturers__D3DESCRIPTION", "list.css"); + $this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, $oManufacturer->getD3LongDescTableColumnName(), "list.css"); return "@d3manufacturerinformation/admin/d3manufacturerlongdesc"; } @@ -79,8 +80,8 @@ class ManufacturerInfoLongdesc extends AdminDetailsController $aParams = Registry::getRequest()->getRequestEscapedParameter("editval"); $oManufacturer->assign($aParams); - if (false === is_null($this->d3GetLongdescParamValue())) { - $oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue()); + if (false === is_null($this->d3GetLongdescParamValue($oManufacturer))) { + $oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue($oManufacturer)); $oManufacturer->save(); } } @@ -102,11 +103,12 @@ class ManufacturerInfoLongdesc extends AdminDetailsController } /** + * @param Manufacturer|D3ManufacturerLongDesc $oManufacturer * @return string */ - public function d3GetLongdescParamValue() :string + public function d3GetLongdescParamValue(Manufacturer $oManufacturer) :string { - return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__D3DESCRIPTION']; + return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")[$oManufacturer->getD3LongDescTableColumnName()]; } /** diff --git a/Modules/Application/Model/D3ManufacturerLongDesc.php b/Modules/Application/Model/D3ManufacturerLongDesc.php index cfaefcb..84b6699 100644 --- a/Modules/Application/Model/D3ManufacturerLongDesc.php +++ b/Modules/Application/Model/D3ManufacturerLongDesc.php @@ -36,4 +36,12 @@ class D3ManufacturerLongDesc extends D3ManufacturerLongDesc_parent { return $this->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME); } + + /** + * @return string + */ + public function getD3LongDescTableColumnName() :string + { + return $sParamName = $this->getViewName(true).'__'.Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME; + } } \ No newline at end of file