From 8f046ed231a6156e239f9f2a586b03da021a4c28 Mon Sep 17 00:00:00 2001 From: MaxBuhe01 Date: Wed, 20 Nov 2024 18:50:18 +0100 Subject: [PATCH] [Changed] php cs fixer adjustments --- .../Admin/ManufacturerInfoLongdesc.php | 245 +++++++++--------- Application/Model/Constants.php | 26 +- .../de/d3manufacturerinformation_lang.php | 21 +- .../en/d3manufacturerinformation_lang.php | 25 +- .../de/d3manufacturerinformation_lang.php | 19 +- .../en/d3manufacturerinformation_lang.php | 23 +- IntelliSenseHelper.php | 36 +-- .../Model/D3ManufacturerLongDesc.php | 84 +++--- .../Model/ManufacturerInfoList.php | 38 ++- metadata.php | 30 ++- migration/data/Version20241023154223.php | 71 +++-- migration/data/Version20241028172608.php | 101 +++++--- 12 files changed, 428 insertions(+), 291 deletions(-) diff --git a/Application/Controller/Admin/ManufacturerInfoLongdesc.php b/Application/Controller/Admin/ManufacturerInfoLongdesc.php index 30d2e2e..f953fee 100644 --- a/Application/Controller/Admin/ManufacturerInfoLongdesc.php +++ b/Application/Controller/Admin/ManufacturerInfoLongdesc.php @@ -1,5 +1,18 @@ + * @link https://www.oxidmodule.com + */ + declare(strict_types=1); namespace D3\ManufacturerInformation\Application\Controller\Admin; @@ -12,118 +25,118 @@ use OxidEsales\Eshop\Core\Registry; class ManufacturerInfoLongdesc extends AdminDetailsController { - /** - * @return string - */ - public function render() - { - parent::render(); - - /** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */ - $this->_aViewData['edit'] = $oManufacturer = oxNew(\OxidEsales\Eshop\Application\Model\Manufacturer::class); - - $sOXID = $this->_aViewData["oxid"] = $this->getEditObjectId(); - if (isset($sOXID) && $sOXID != "-1") { - // load object - $d3manufacturerlang = \OxidEsales\Eshop\Core\Registry::getRequest()->getRequestEscapedParameter("catlang"); - - if (!isset($d3manufacturerlang)) { - $d3manufacturerlang = $this->_iEditLang; - } - - $this->_aViewData["catlang"] = $d3manufacturerlang; - - $oManufacturer->loadInLang($d3manufacturerlang, $sOXID); - - //Disable editing for derived items - if ($oManufacturer->isDerived()) { - $this->_aViewData['readonly'] = true; - } - - foreach (\OxidEsales\Eshop\Core\Registry::getLang()->getLanguageNames() as $id => $language) { - $oLang = new \stdClass(); - $oLang->sLangDesc = $language; - $oLang->selected = ($id == $this->_iEditLang); - $this->_aViewData["otherlang"][$id] = clone $oLang; - } - } - - $this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, $oManufacturer->getD3LongDescTableColumnName(), "list.css"); - - return "@d3manufacturerinformation/admin/d3manufacturerlongdesc"; - } - - /** - * @return void - * @throws \Exception - */ - public function save() - { - parent::save(); - - $iManufacturerLang = intval(\OxidEsales\Eshop\Core\Registry::getRequest()->getRequestEscapedParameter("catlang")); - $sOXID = $this->getEditObjectId(); - $this->setEditObjectId($sOXID); - - if ($sOXID == "-1") { - return; - } - - /** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */ - $oManufacturer = oxNew(Manufacturer::class); - $oManufacturer->loadInLang($iManufacturerLang, $sOXID); - - if (!$oManufacturer->load($sOXID)) { - return; - } - - $aParams = Registry::getRequest()->getRequestEscapedParameter("editval"); - $oManufacturer->assign($aParams); - - if (false === is_null($this->d3GetLongdescParamValue($oManufacturer))) { - $oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue($oManufacturer)); - $oManufacturer->save(); - } - } - - /** - * @param $oManufacturer - * @param $sField - * @return string - */ - protected function getEditValue($oManufacturer, $sField) - { - $sEditObjectValue = ''; - - if ($oManufacturer and $oManufacturer->getId()) { - $sEditObjectValue = $oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME); - } - - return $sEditObjectValue; - } - - /** - * @param Manufacturer|D3ManufacturerLongDesc $oManufacturer - * @return string - */ - public function d3GetLongdescParamValue(Manufacturer $oManufacturer) :string - { - return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")[$oManufacturer->getD3LongDescTableColumnName()]; - } - - /** - * inhaltliche Uebernahme analog Article_Main - * wird genutzt zum Abspeichern der Artikel-Langbeschreibung - * - * @param $sValue - * - * @return mixed - */ - protected function processLongDesc($sValue) - { - $aSearch = [' ', '&', '"', '&lang=', '

 

', '

 

']; - $aReplace = [' ', '&', '"', '&lang=', '', '']; - - return str_replace($aSearch, $aReplace, $sValue); - } -} \ No newline at end of file + /** + * @return string + */ + public function render() + { + parent::render(); + + /** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */ + $this->_aViewData['edit'] = $oManufacturer = oxNew(\OxidEsales\Eshop\Application\Model\Manufacturer::class); + + $sOXID = $this->_aViewData["oxid"] = $this->getEditObjectId(); + if (isset($sOXID) && $sOXID != "-1") { + // load object + $d3manufacturerlang = \OxidEsales\Eshop\Core\Registry::getRequest()->getRequestEscapedParameter("catlang"); + + if (!isset($d3manufacturerlang)) { + $d3manufacturerlang = $this->_iEditLang; + } + + $this->_aViewData["catlang"] = $d3manufacturerlang; + + $oManufacturer->loadInLang($d3manufacturerlang, $sOXID); + + //Disable editing for derived items + if ($oManufacturer->isDerived()) { + $this->_aViewData['readonly'] = true; + } + + foreach (\OxidEsales\Eshop\Core\Registry::getLang()->getLanguageNames() as $id => $language) { + $oLang = new \stdClass(); + $oLang->sLangDesc = $language; + $oLang->selected = ($id == $this->_iEditLang); + $this->_aViewData["otherlang"][$id] = clone $oLang; + } + } + + $this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, $oManufacturer->getD3LongDescTableColumnName(), "list.css"); + + return "@d3manufacturerinformation/admin/d3manufacturerlongdesc"; + } + + /** + * @return void + * @throws \Exception + */ + public function save() + { + parent::save(); + + $iManufacturerLang = intval(\OxidEsales\Eshop\Core\Registry::getRequest()->getRequestEscapedParameter("catlang")); + $sOXID = $this->getEditObjectId(); + $this->setEditObjectId($sOXID); + + if ($sOXID == "-1") { + return; + } + + /** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */ + $oManufacturer = oxNew(Manufacturer::class); + $oManufacturer->loadInLang($iManufacturerLang, $sOXID); + + if (!$oManufacturer->load($sOXID)) { + return; + } + + $aParams = Registry::getRequest()->getRequestEscapedParameter("editval"); + $oManufacturer->assign($aParams); + + if (false === is_null($this->d3GetLongdescParamValue($oManufacturer))) { + $oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue($oManufacturer)); + $oManufacturer->save(); + } + } + + /** + * @param $oManufacturer + * @param $sField + * @return string + */ + protected function getEditValue($oManufacturer, $sField) + { + $sEditObjectValue = ''; + + if ($oManufacturer and $oManufacturer->getId()) { + $sEditObjectValue = $oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME); + } + + return $sEditObjectValue; + } + + /** + * @param Manufacturer|D3ManufacturerLongDesc $oManufacturer + * @return string + */ + public function d3GetLongdescParamValue(Manufacturer $oManufacturer): string + { + return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")[$oManufacturer->getD3LongDescTableColumnName()]; + } + + /** + * inhaltliche Uebernahme analog Article_Main + * wird genutzt zum Abspeichern der Artikel-Langbeschreibung + * + * @param $sValue + * + * @return mixed + */ + protected function processLongDesc($sValue) + { + $aSearch = [' ', '&', '"', '&lang=', '

 

', '

 

']; + $aReplace = [' ', '&', '"', '&lang=', '', '']; + + return str_replace($aSearch, $aReplace, $sValue); + } +} diff --git a/Application/Model/Constants.php b/Application/Model/Constants.php index 26e85ab..1ab39cd 100644 --- a/Application/Model/Constants.php +++ b/Application/Model/Constants.php @@ -1,14 +1,26 @@ + * @link https://www.oxidmodule.com + */ + declare(strict_types=1); namespace D3\ManufacturerInformation\Application\Model; - class Constants { - public const OXID_MODULE_ID = 'd3manufacturerinformation'; - - // Tables and Database - public const D3_OXMANUFACTURERS_LONGDESC_FIELDNAME = 'd3description'; -} \ No newline at end of file + public const OXID_MODULE_ID = 'd3manufacturerinformation'; + + // Tables and Database + public const D3_OXMANUFACTURERS_LONGDESC_FIELDNAME = 'd3description'; +} diff --git a/Application/views/admin_smarty/de/d3manufacturerinformation_lang.php b/Application/views/admin_smarty/de/d3manufacturerinformation_lang.php index b9f528f..e4e5a6b 100644 --- a/Application/views/admin_smarty/de/d3manufacturerinformation_lang.php +++ b/Application/views/admin_smarty/de/d3manufacturerinformation_lang.php @@ -1,13 +1,26 @@ + * @link https://www.oxidmodule.com + */ + $sLangName = "Deutsch"; // ------------------------------- // RESOURCE IDENTITFIER = STRING // ------------------------------- -$aLang = array( +$aLang = [ 'charset' => 'UTF-8', - + 'mxd3manufacturerinfolongdesc' => 'Langtext', 'SHOP_MODULE_GROUP_d3manufacturerinformation_main' => 'Einstellungen', - 'SHOP_MODULE_d3manufacturerinformation_showManufacturertextOnDetailsPage' => 'vorhandene Herstellertexte auf Artikeldetails als Tab anzeigen' -); \ No newline at end of file + 'SHOP_MODULE_d3manufacturerinformation_showManufacturertextOnDetailsPage' => 'vorhandene Herstellertexte auf Artikeldetails als Tab anzeigen', +]; diff --git a/Application/views/admin_smarty/en/d3manufacturerinformation_lang.php b/Application/views/admin_smarty/en/d3manufacturerinformation_lang.php index 22225ce..834195b 100644 --- a/Application/views/admin_smarty/en/d3manufacturerinformation_lang.php +++ b/Application/views/admin_smarty/en/d3manufacturerinformation_lang.php @@ -1,13 +1,26 @@ + * @link https://www.oxidmodule.com + */ + $sLangName = "Deutsch"; // ------------------------------- // RESOURCE IDENTITFIER = STRING // ------------------------------- -$aLang = array( - 'charset' => 'UTF-8', - - 'mxd3manufacturerinfolongdesc' => 'Text', +$aLang = [ + 'charset' => 'UTF-8', + + 'mxd3manufacturerinfolongdesc' => 'Text', 'SHOP_MODULE_GROUP_d3manufacturerinformation_main' => 'Settings', - 'SHOP_MODULE_d3manufacturerinformation_showManufacturertextOnDetailsPage' => 'display existing manufacturer texts on item details as a tab' -); \ No newline at end of file + 'SHOP_MODULE_d3manufacturerinformation_showManufacturertextOnDetailsPage' => 'display existing manufacturer texts on item details as a tab', +]; diff --git a/Application/views/admin_twig/de/d3manufacturerinformation_lang.php b/Application/views/admin_twig/de/d3manufacturerinformation_lang.php index 73f4f84..d2f4e68 100644 --- a/Application/views/admin_twig/de/d3manufacturerinformation_lang.php +++ b/Application/views/admin_twig/de/d3manufacturerinformation_lang.php @@ -1,11 +1,24 @@ + * @link https://www.oxidmodule.com + */ + $sLangName = "Deutsch"; // ------------------------------- // RESOURCE IDENTITFIER = STRING // ------------------------------- -$aLang = array( +$aLang = [ 'charset' => 'UTF-8', - + 'mxd3manufacturerinfolongdesc' => 'Langtext', -); \ No newline at end of file +]; diff --git a/Application/views/admin_twig/en/d3manufacturerinformation_lang.php b/Application/views/admin_twig/en/d3manufacturerinformation_lang.php index a86fe8b..d585f71 100644 --- a/Application/views/admin_twig/en/d3manufacturerinformation_lang.php +++ b/Application/views/admin_twig/en/d3manufacturerinformation_lang.php @@ -1,11 +1,24 @@ + * @link https://www.oxidmodule.com + */ + $sLangName = "Deutsch"; // ------------------------------- // RESOURCE IDENTITFIER = STRING // ------------------------------- -$aLang = array( - 'charset' => 'UTF-8', - - 'mxd3manufacturerinfolongdesc' => 'Text', -); \ No newline at end of file +$aLang = [ + 'charset' => 'UTF-8', + + 'mxd3manufacturerinfolongdesc' => 'Text', +]; diff --git a/IntelliSenseHelper.php b/IntelliSenseHelper.php index 3851bfd..b247e4d 100644 --- a/IntelliSenseHelper.php +++ b/IntelliSenseHelper.php @@ -1,24 +1,28 @@ - * @link http://www.oxidmodule.com + * @author D3 Data Development - Max Buhe, Daniel Seifert + * @link https://www.oxidmodule.com */ namespace D3\ManufacturerInformation\Modules\Application\Model{ - - use OxidEsales\Eshop\Application\Model\Manufacturer; - use OxidEsales\Eshop\Application\Model\ManufacturerList; - - class D3ManufacturerLongDesc_parent extends Manufacturer {} - - class ManufacturerInfoList_parent extends ManufacturerList {} -} \ No newline at end of file + + use OxidEsales\Eshop\Application\Model\Manufacturer; + use OxidEsales\Eshop\Application\Model\ManufacturerList; + + class D3ManufacturerLongDesc_parent extends Manufacturer + { + } + + class ManufacturerInfoList_parent extends ManufacturerList + { + } +} diff --git a/Modules/Application/Model/D3ManufacturerLongDesc.php b/Modules/Application/Model/D3ManufacturerLongDesc.php index 84b6699..8384d56 100644 --- a/Modules/Application/Model/D3ManufacturerLongDesc.php +++ b/Modules/Application/Model/D3ManufacturerLongDesc.php @@ -1,47 +1,59 @@ + * @link https://www.oxidmodule.com + */ + declare(strict_types=1); namespace D3\ManufacturerInformation\Modules\Application\Model; - use D3\ManufacturerInformation\Application\Model\Constants; use OxidEsales\Eshop\Application\Model\Manufacturer; use OxidEsales\Eshop\Core\Registry; class D3ManufacturerLongDesc extends D3ManufacturerLongDesc_parent { - /** - * @param string $sValue - * @return void - */ - public function d3SetLongdesc(string $sValue) :bool - { - if ($this->getId() and $this->isLoaded()){ - try { - $this->assign([Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME => $sValue]); - $this->save(); - }catch (\Exception $exception){ - Registry::getLogger()->error($exception->getMessage()); - } - } - - return true; - } - - /** - * @return string - */ - public function d3GetLongdesc(): string - { - 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 + /** + * @param string $sValue + * @return void + */ + public function d3SetLongdesc(string $sValue): bool + { + if ($this->getId() and $this->isLoaded()) { + try { + $this->assign([Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME => $sValue]); + $this->save(); + } catch (\Exception $exception) { + Registry::getLogger()->error($exception->getMessage()); + } + } + + return true; + } + + /** + * @return string + */ + public function d3GetLongdesc(): string + { + return $this->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME); + } + + /** + * @return string + */ + public function getD3LongDescTableColumnName(): string + { + return $sParamName = $this->getViewName(true).'__'.Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME; + } +} diff --git a/Modules/Application/Model/ManufacturerInfoList.php b/Modules/Application/Model/ManufacturerInfoList.php index c5634ae..78c138d 100644 --- a/Modules/Application/Model/ManufacturerInfoList.php +++ b/Modules/Application/Model/ManufacturerInfoList.php @@ -1,10 +1,22 @@ + * @link https://www.oxidmodule.com + */ + declare(strict_types=1); namespace D3\ManufacturerInformation\Modules\Application\Model; - use D3\ManufacturerInformation\Application\Model\Constants; use OxidEsales\Eshop\Application\Model\Manufacturer; use OxidEsales\Eshop\Application\Model\ManufacturerList; @@ -12,14 +24,14 @@ use OxidEsales\Eshop\Core\Field; class ManufacturerInfoList extends ManufacturerInfoList_parent { - /** - * @param Manufacturer|D3ManufacturerLongDesc $oManufacturer - * @return void - */ - protected function addCategoryFields($oManufacturer) - { - parent::addCategoryFields($oManufacturer); - - $oManufacturer->oxcategories__oxlongdesc = new Field($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME), Field::T_RAW); - } -} \ No newline at end of file + /** + * @param Manufacturer|D3ManufacturerLongDesc $oManufacturer + * @return void + */ + protected function addCategoryFields($oManufacturer) + { + parent::addCategoryFields($oManufacturer); + + $oManufacturer->oxcategories__oxlongdesc = new Field($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME), Field::T_RAW); + } +} diff --git a/metadata.php b/metadata.php index a97c2b8..f0287ad 100644 --- a/metadata.php +++ b/metadata.php @@ -1,13 +1,15 @@ + * @author D3 Data Development - Max Buhe, Daniel Seifert * @link https://www.oxidmodule.com */ @@ -27,11 +29,11 @@ $sMetadataVersion = '2.1'; */ $aModule = [ 'id' => Constants::OXID_MODULE_ID, - 'title' => [ - 'de' => '(D3) Herstellerinformationen', - 'en' => '(D3) Manufacturer information', - ], - 'description' => [ + 'title' => [ + 'de' => '(D3) Herstellerinformationen', + 'en' => '(D3) Manufacturer information', + ], + 'description' => [ 'de' => 'fügt Informationen der Hersteller zur Artikelliste hinzu', 'en' => 'adds manufacturer information to the article list', ], @@ -41,21 +43,21 @@ $aModule = [ 'email' => 'support@shopmodule.com', 'url' => 'https://www.oxidmodule.com/', 'controllers' => [ - "d3manufacturerinfolongdesc" => ManufacturerInfoLongdesc::class + "d3manufacturerinfolongdesc" => ManufacturerInfoLongdesc::class, ], 'extend' => [ - OEManufacturer::class => D3ManufacturerLongDesc::class, - OEManufacturerList::class => ManufacturerInfoList::class + OEManufacturer::class => D3ManufacturerLongDesc::class, + OEManufacturerList::class => ManufacturerInfoList::class, ], 'templates' => [ - '@' . Constants::OXID_MODULE_ID . '/admin/d3manufacturerlongdesc.tpl' => 'views/smarty/admin/d3manufacturerlongdesc.tpl', + '@' . Constants::OXID_MODULE_ID . '/admin/d3manufacturerlongdesc.tpl' => 'views/smarty/admin/d3manufacturerlongdesc.tpl', ], 'settings' => [ [ 'group' => $sModuleId.'_main', 'name' => $sModuleId.'_showManufacturertextOnDetailsPage', 'type' => 'bool', - 'value' => true + 'value' => true, ], ], 'blocks' => [ @@ -69,5 +71,5 @@ $aModule = [ 'block' => 'details_tabs_invite', 'file' => 'Application/views/blocks/page/details/inc/details_tabs_invite.html.tpl', ], - ] + ], ]; diff --git a/migration/data/Version20241023154223.php b/migration/data/Version20241023154223.php index 18af8f6..67d04b9 100644 --- a/migration/data/Version20241023154223.php +++ b/migration/data/Version20241023154223.php @@ -1,5 +1,18 @@ + * @link https://www.oxidmodule.com + */ + declare(strict_types=1); namespace D3\ManufacturerInformation\Migrations; @@ -13,36 +26,38 @@ use Doctrine\Migrations\AbstractMigration; */ final class Version20241023154223 extends AbstractMigration { - public function getDescription() : string + public function getDescription(): string { return 'Adds the D3 manufacturer longdesc column'; } - - public function up(Schema $schema) : void - { - $this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - - $this->d3AddLongdescColumnToOxmanufacturers($schema); - } - public function down(Schema $schema) : void - {} - - /** - * @param Schema $schema - * @return void - * @throws \Doctrine\DBAL\Schema\SchemaException - */ - public function d3AddLongdescColumnToOxmanufacturers(Schema $schema){ - $table = !$schema->hasTable('oxmanufacturers') ? - $schema->createTable('oxmanufacturers') : - $schema->getTable('oxmanufacturers'); - - // Beschreibung - if (!$table->hasColumn('D3DESCRIPTION')) { - $table->addColumn('D3DESCRIPTION', (new TextType())->getName()) - ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) - ->setNotnull(true); - } - } + public function up(Schema $schema): void + { + $this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); + + $this->d3AddLongdescColumnToOxmanufacturers($schema); + } + + public function down(Schema $schema): void + { + } + + /** + * @param Schema $schema + * @return void + * @throws \Doctrine\DBAL\Schema\SchemaException + */ + public function d3AddLongdescColumnToOxmanufacturers(Schema $schema) + { + $table = !$schema->hasTable('oxmanufacturers') ? + $schema->createTable('oxmanufacturers') : + $schema->getTable('oxmanufacturers'); + + // Beschreibung + if (!$table->hasColumn('D3DESCRIPTION')) { + $table->addColumn('D3DESCRIPTION', (new TextType())->getName()) + ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) + ->setNotnull(true); + } + } } diff --git a/migration/data/Version20241028172608.php b/migration/data/Version20241028172608.php index 11b7b93..c756aee 100644 --- a/migration/data/Version20241028172608.php +++ b/migration/data/Version20241028172608.php @@ -1,5 +1,18 @@ + * @link https://www.oxidmodule.com + */ + declare(strict_types=1); namespace D3\ManufacturerInformation\Migrations; @@ -13,50 +26,52 @@ use Doctrine\Migrations\AbstractMigration; */ final class Version20241028172608 extends AbstractMigration { - public function getDescription() : string + public function getDescription(): string { - return 'Adds multilang tables for the D3 manufacturer longdesc'; + return 'Adds multilang tables for the D3 manufacturer longdesc'; } - - public function up(Schema $schema) : void - { - $this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); - - $this->d3AddLongdescMultilangColumnsToOxmanufacturers($schema); - } - public function down(Schema $schema) : void - {} - - /** - * @param Schema $schema - * @return void - * @throws \Doctrine\DBAL\Schema\SchemaException - */ - public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema){ - $table = !$schema->hasTable('oxmanufacturers') ? - $schema->createTable('oxmanufacturers') : - $schema->getTable('oxmanufacturers'); - - // lang 1 - if (!$table->hasColumn('D3DESCRIPTION_1')) { - $table->addColumn('D3DESCRIPTION_1', (new TextType())->getName()) - ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) - ->setNotnull(true); - } - - // lang 2 - if (!$table->hasColumn('D3DESCRIPTION_2')) { - $table->addColumn('D3DESCRIPTION_2', (new TextType())->getName()) - ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) - ->setNotnull(true); - } - - // lang 3 - if (!$table->hasColumn('D3DESCRIPTION_3')) { - $table->addColumn('D3DESCRIPTION_3', (new TextType())->getName()) - ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) - ->setNotnull(true); - } - } + public function up(Schema $schema): void + { + $this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); + + $this->d3AddLongdescMultilangColumnsToOxmanufacturers($schema); + } + + public function down(Schema $schema): void + { + } + + /** + * @param Schema $schema + * @return void + * @throws \Doctrine\DBAL\Schema\SchemaException + */ + public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema) + { + $table = !$schema->hasTable('oxmanufacturers') ? + $schema->createTable('oxmanufacturers') : + $schema->getTable('oxmanufacturers'); + + // lang 1 + if (!$table->hasColumn('D3DESCRIPTION_1')) { + $table->addColumn('D3DESCRIPTION_1', (new TextType())->getName()) + ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) + ->setNotnull(true); + } + + // lang 2 + if (!$table->hasColumn('D3DESCRIPTION_2')) { + $table->addColumn('D3DESCRIPTION_2', (new TextType())->getName()) + ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) + ->setNotnull(true); + } + + // lang 3 + if (!$table->hasColumn('D3DESCRIPTION_3')) { + $table->addColumn('D3DESCRIPTION_3', (new TextType())->getName()) + ->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT) + ->setNotnull(true); + } + } }