improve code style by CS Fixer

This commit is contained in:
Daniel Seifert 2024-11-19 10:50:33 +01:00
parent e4bc788538
commit ef59e0a090
13 changed files with 240 additions and 94 deletions

View File

@ -1 +1 @@
copyAsIsFiles=metadata.php, IntelliSenseHelper.php, migration, Application/views
copyAsIsFiles=metadata.php, .php-cs-fixer.php, IntelliSenseHelper.php, migration, Application/views

34
.php-cs-fixer.php Normal file
View File

@ -0,0 +1,34 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;
$header = <<<EOF
Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
https://www.d3data.de
@copyright (C) D3 Data Development (Inh. Thomas Dartsch)
@author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
@link https://www.oxidmodule.com
EOF;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PHP80Migration' => true,
'@PSR12' => true,
'header_comment' => [
'comment_type' => 'PHPDoc',
'header' => $header,
'location' => 'after_open',
'separate' => 'both',
],
'php_unit_test_class_requires_covers' => true,
'doctrine_annotation_indentation' => true,
])
->setFinder($finder)
;

View File

@ -1,5 +1,18 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\ManufacturerInformation\Application\Controller\Admin;
@ -18,27 +31,27 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
public function render()
{
parent::render();
$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::getConfig()->getRequestParameter("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;
@ -46,12 +59,12 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
$this->_aViewData["otherlang"][$id] = clone $oLang;
}
}
$this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, "oxmanufacturers__d3description", "list.tpl.css");
return "d3manufacturerlongdesc.tpl";
}
/**
* @return void
* @throws \Exception
@ -59,32 +72,32 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
public function save()
{
parent::save();
$iManufacturerLang = intval(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("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->d3SetLongdesc($this->d3GetLongdescParamValue());
$oManufacturer->save();
}
}
/**
* Returns string which must be edited by editor
*
@ -97,22 +110,22 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
protected function _getEditValue($oManufacturer, $sField) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
{
$sEditObjectValue = '';
if ($oManufacturer and $oManufacturer->getId()) {
$sEditObjectValue = $this->_processEditValue($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME));
}
return $sEditObjectValue;
}
/**
* @return string
*/
public function d3GetLongdescParamValue() :string
public function d3GetLongdescParamValue(): string
{
return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__d3description'];
}
/**
* inhaltliche Uebernahme analog Article_Main
* wird genutzt zum Abspeichern der Artikel-Langbeschreibung
@ -125,7 +138,7 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
{
$aSearch = ['&amp;nbsp;', '&amp;', '&quot;', '&lang=', '<p>&nbsp;</p>', '<p>&nbsp; </p>'];
$aReplace = ['&nbsp;', '&', '"', '&amp;lang=', '', ''];
return str_replace($aSearch, $aReplace, $sValue);
}
}
}

View File

@ -1,14 +1,26 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @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';
}
}

View File

@ -1,13 +1,26 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @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'
);
'SHOP_MODULE_d3manufacturerinformation_showManufacturertextOnDetailsPage' => 'vorhandene Herstellertexte auf Artikeldetails als Tab anzeigen',
];

View File

@ -1,13 +1,26 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
$sLangName = "Deutsch";
// -------------------------------
// RESOURCE IDENTITFIER = STRING
// -------------------------------
$aLang = array(
$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'
);
'SHOP_MODULE_d3manufacturerinformation_showManufacturertextOnDetailsPage' => 'display existing manufacturer texts on item details as a tab',
];

View File

@ -1,21 +1,23 @@
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
* http://www.shopmodule.com
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
namespace D3\ManufacturerInformation\Modules\Application\Model{
use OxidEsales\Eshop\Application\Model\Manufacturer;
class D3ManufacturerLongDesc_parent extends Manufacturer {}
}
class D3ManufacturerLongDesc_parent extends Manufacturer
{
}
}

View File

@ -1,10 +1,22 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @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\Field;
@ -16,20 +28,20 @@ class D3ManufacturerLongDesc extends D3ManufacturerLongDesc_parent
* @param string $sValue
* @return void
*/
public function d3SetLongdesc(string $sValue) :bool
public function d3SetLongdesc(string $sValue): bool
{
if ($this->getId() and $this->isLoaded()){
if ($this->getId() and $this->isLoaded()) {
try {
$this->assign([Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME => $sValue]);
$this->save();
}catch (\Exception $exception){
} catch (\Exception $exception) {
Registry::getLogger()->error($exception->getMessage());
}
}
return true;
}
/**
* @return Field
*/
@ -38,4 +50,4 @@ class D3ManufacturerLongDesc extends D3ManufacturerLongDesc_parent
$longName = $this->getCoreTableName().'__'.strtolower(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME);
return $this->$longName;
}
}
}

View File

@ -1,10 +1,22 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @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;
@ -19,7 +31,7 @@ class ManufacturerInfoList extends ManufacturerInfoList_parent
protected function _addCategoryFields($oManufacturer)
{
parent::_addCategoryFields($oManufacturer);
$oManufacturer->oxcategories__oxlongdesc = new Field($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME), Field::T_RAW);
}
}
}

View File

@ -24,13 +24,12 @@
"proprietary"
],
"require": {
"php": "~7.0 || ~8.0",
"php": "~7.1 || ~8.0",
"oxid-esales/oxideshop-ce": "v6.6.0 - v6.14.3"
},
"require-dev": {
"phpunit/phpunit" : "^9.5",
"friendsofphp/php-cs-fixer": "^3.9",
"phpstan/phpstan": "^1.8"
"oxid-esales/oxideshop-ce": "~6.14.0",
"friendsofphp/php-cs-fixer": "^3.9"
},
"extra": {
"oxideshop": {
@ -47,5 +46,9 @@
"psr-4": {
"D3\\ManufacturerInformation\\": "../../../source/modules/d3/manufacturerinformation"
}
},
"scripts": {
"php-cs-fixer_audit": "./vendor/bin/php-cs-fixer list-files --config=./vendor/d3/manufacturerinformation/.php-cs-fixer.php",
"php-cs-fixer_fix": "./vendor/bin/php-cs-fixer fix --config=./vendor/d3/manufacturerinformation/.php-cs-fixer.php"
}
}

View File

@ -1,18 +1,20 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
use D3\ManufacturerInformation\Application\Controller\Admin\ManufacturerInfoLongdesc;
use D3\ManufacturerInformation\Application\Model\Constants;
use D3\ManufacturerInformation\Modules\Application\Model\D3ManufacturerLongDesc;
@ -41,11 +43,11 @@ $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
OEManufacturerList::class => ManufacturerInfoList::class,
],
'templates' => [
'd3manufacturerlongdesc.tpl' => 'd3/manufacturerinformation/Application/views/admin/tpl/d3manufacturer_longdesc.tpl',
@ -55,7 +57,7 @@ $aModule = [
'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',
],
]
],
];

View File

@ -1,5 +1,18 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\ManufacturerInformation\Migrations;
@ -13,31 +26,33 @@ 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
public function up(Schema $schema): void
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$this->d3AddLongdescColumnToOxmanufacturers($schema);
}
public function down(Schema $schema) : void
{}
public function down(Schema $schema): void
{
}
/**
* @param Schema $schema
* @return void
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function d3AddLongdescColumnToOxmanufacturers(Schema $schema){
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())

View File

@ -1,5 +1,18 @@
<?php
/**
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\ManufacturerInformation\Migrations;
@ -13,45 +26,47 @@ 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';
}
public function up(Schema $schema) : void
public function up(Schema $schema): void
{
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
$this->d3AddLongdescMultilangColumnsToOxmanufacturers($schema);
}
public function down(Schema $schema) : void
{}
public function down(Schema $schema): void
{
}
/**
* @param Schema $schema
* @return void
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema){
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())