improve code

This commit is contained in:
Daniel Seifert 2025-01-03 15:11:14 +01:00
parent c84a109281
commit 77bd789f14
5 changed files with 27 additions and 12 deletions

View File

@ -94,8 +94,8 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
$aParams = Registry::getRequest()->getRequestEscapedParameter("editval"); $aParams = Registry::getRequest()->getRequestEscapedParameter("editval");
$oManufacturer->assign($aParams); $oManufacturer->assign($aParams);
if (false === is_null($this->d3GetLongdescParamValue($oManufacturer))) { if (false === is_null($this->d3GetLongdescParamValue())) {
$oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue($oManufacturer)); $oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue());
$oManufacturer->save(); $oManufacturer->save();
} }
} }
@ -103,7 +103,7 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
/** /**
* @return string * @return string
*/ */
public function d3GetLongdescParamValue(Manufacturer $oManufacturer): string public function d3GetLongdescParamValue(): string
{ {
return (string) Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__d3description']; return (string) Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__d3description'];
} }
@ -114,13 +114,13 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
* *
* @param $sValue * @param $sValue
* *
* @return mixed * @return string
*/ */
protected function processLongDesc($sValue): mixed protected function processLongDesc($sValue): string
{ {
$aSearch = ['&amp;nbsp;', '&amp;', '&quot;', '&lang=', '<p>&nbsp;</p>', '<p>&nbsp; </p>']; $aSearch = ['&amp;nbsp;', '&amp;', '&quot;', '&lang=', '<p>&nbsp;</p>', '<p>&nbsp; </p>'];
$aReplace = ['&nbsp;', '&', '"', '&amp;lang=', '', '']; $aReplace = ['&nbsp;', '&', '"', '&amp;lang=', '', ''];
return str_replace($aSearch, $aReplace, $sValue); return (string) str_replace($aSearch, $aReplace, $sValue);
} }
} }

View File

@ -18,6 +18,7 @@ declare(strict_types=1);
namespace D3\ManufacturerInformation\Modules\Application\Model; namespace D3\ManufacturerInformation\Modules\Application\Model;
use D3\ManufacturerInformation\Application\Model\Constants; use D3\ManufacturerInformation\Application\Model\Constants;
use Exception;
use OxidEsales\Eshop\Core\Field; use OxidEsales\Eshop\Core\Field;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
@ -33,7 +34,7 @@ class D3ManufacturerLongDesc extends D3ManufacturerLongDesc_parent
try { try {
$this->assign([Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME => $sValue]); $this->assign([Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME => $sValue]);
$this->save(); $this->save();
} catch (\Exception $exception) { } catch ( Exception $exception) {
Registry::getLogger()->error($exception->getMessage()); Registry::getLogger()->error($exception->getMessage());
} }
} }
@ -42,9 +43,9 @@ class D3ManufacturerLongDesc extends D3ManufacturerLongDesc_parent
} }
/** /**
* @return field * @return Field
*/ */
public function d3GetLongdesc(): field public function d3GetLongdesc(): Field
{ {
$longName = $this->getFieldLongName(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME); $longName = $this->getFieldLongName(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME);
return $this->$longName ?: oxNew(Field::class); return $this->$longName ?: oxNew(Field::class);

View File

@ -20,18 +20,22 @@ namespace D3\ManufacturerInformation\Modules\Application\Model;
use OxidEsales\Eshop\Application\Model\Manufacturer; use OxidEsales\Eshop\Application\Model\Manufacturer;
use OxidEsales\Eshop\Core\Field; use OxidEsales\Eshop\Core\Field;
use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Registry;
use OxidEsales\Eshop\Core\UtilsView;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService; use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererInterface; use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class ManufacturerInfoList extends ManufacturerInfoList_parent class ManufacturerInfoList extends ManufacturerInfoList_parent
{ {
/** /**
* @param Manufacturer|D3ManufacturerLongDesc $oManufacturer * @param Manufacturer|D3ManufacturerLongDesc $oManufacturer
*
* @return void * @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/ */
protected function addCategoryFields($oManufacturer): void protected function addCategoryFields($oManufacturer): void
{ {
@ -64,6 +68,11 @@ class ManufacturerInfoList extends ManufacturerInfoList_parent
} }
} }
/**
* @return TemplateRendererInterface
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
private function getRenderer(): TemplateRendererInterface private function getRenderer(): TemplateRendererInterface
{ {
return ContainerFactory::getInstance()->getContainer()->get(TemplateRendererBridgeInterface::class)->getTemplateRenderer(); return ContainerFactory::getInstance()->getContainer()->get(TemplateRendererBridgeInterface::class)->getTemplateRenderer();

View File

@ -18,6 +18,7 @@ declare(strict_types=1);
namespace D3\ManufacturerInformation\Migrations; namespace D3\ManufacturerInformation\Migrations;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\TextType;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
@ -45,7 +46,7 @@ final class Version20241023154223 extends AbstractMigration
/** /**
* @param Schema $schema * @param Schema $schema
* @return void * @return void
* @throws \Doctrine\DBAL\Schema\SchemaException * @throws SchemaException
*/ */
public function d3AddLongdescColumnToOxmanufacturers(Schema $schema) public function d3AddLongdescColumnToOxmanufacturers(Schema $schema)
{ {

View File

@ -17,7 +17,9 @@ declare(strict_types=1);
namespace D3\ManufacturerInformation\Migrations; namespace D3\ManufacturerInformation\Migrations;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\TextType;
use Doctrine\Migrations\AbstractMigration; use Doctrine\Migrations\AbstractMigration;
@ -44,8 +46,10 @@ final class Version20241028172608 extends AbstractMigration
/** /**
* @param Schema $schema * @param Schema $schema
*
* @return void * @return void
* @throws \Doctrine\DBAL\Schema\SchemaException * @throws Exception
* @throws SchemaException
*/ */
public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema) public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema)
{ {