From a193e9b413d2cc64b7ca75977bca05c002811d0f Mon Sep 17 00:00:00 2001 From: Henning Leutz <leutz@pcsg.de> Date: Wed, 2 Aug 2023 14:17:25 +0200 Subject: [PATCH] style: code style --- ajax/backend/activate.php | 3 +- .../articleList/getShippingPriceFactor.php | 2 +- ajax/backend/create.php | 6 +- ajax/backend/deactivate.php | 4 +- ajax/backend/getShippingList.php | 4 +- ajax/backend/rules/create.php | 6 +- ajax/backend/rules/delete.php | 5 +- ajax/backend/rules/getList.php | 10 ++-- ajax/backend/rules/getRules.php | 8 +-- .../rules/settings/getUnitFieldSetting.php | 4 +- ajax/backend/rules/update.php | 4 +- .../shippingStatus/getNotificationText.php | 2 +- ajax/backend/shippingStatus/list.php | 6 +- ajax/backend/shippingStatus/update.php | 2 +- ajax/backend/update.php | 2 +- .../Shipping/Api/AbstractShippingEntry.php | 10 ++-- .../Shipping/Api/AbstractShippingProvider.php | 2 - .../ERP/Shipping/Api/AbstractShippingType.php | 2 +- .../Shipping/Methods/Digital/ShippingType.php | 28 ++++++---- .../Methods/Standard/ShippingType.php | 10 ++-- .../Shipping/Methods/Standard/___Shipping.php | 55 ------------------- .../ERP/Shipping/Order/ShippingAddress.php | 16 +++--- 22 files changed, 69 insertions(+), 122 deletions(-) delete mode 100644 src/QUI/ERP/Shipping/Methods/Standard/___Shipping.php diff --git a/ajax/backend/activate.php b/ajax/backend/activate.php index ee99951..42dce9d 100644 --- a/ajax/backend/activate.php +++ b/ajax/backend/activate.php @@ -12,10 +12,11 @@ * @param integer $shippingId * @return array */ + QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_activate', function ($shippingId) { - $Shipping = new Factory(); + $Shipping = new Factory(); $ShippingEntry = $Shipping->getChild($shippingId); $ShippingEntry->activate(); diff --git a/ajax/backend/articleList/getShippingPriceFactor.php b/ajax/backend/articleList/getShippingPriceFactor.php index 8b42ca8..398cefa 100644 --- a/ajax/backend/articleList/getShippingPriceFactor.php +++ b/ajax/backend/articleList/getShippingPriceFactor.php @@ -16,7 +16,7 @@ 'package_quiqqer_shipping_ajax_backend_articleList_getShippingPriceFactor', function ($shippingId) { $Shipping = Shipping::getInstance()->getShippingEntry($shippingId); - + return [ 'title' => $Shipping->getTitle(), 'price' => $Shipping->getPrice() diff --git a/ajax/backend/create.php b/ajax/backend/create.php index e5c5e8e..56e83e4 100644 --- a/ajax/backend/create.php +++ b/ajax/backend/create.php @@ -4,8 +4,8 @@ * This file contains package_quiqqer_shipping_ajax_backend_create */ -use \QUI\ERP\Shipping\Types\Factory; -use \QUI\ERP\Shipping\Shipping; +use QUI\ERP\Shipping\Shipping; +use QUI\ERP\Shipping\Types\Factory; /** * Create a new shipping method @@ -17,7 +17,7 @@ function ($shippingType) { $Type = Shipping::getInstance()->getShippingType($shippingType); - $Factory = new Factory(); + $Factory = new Factory(); $Shipping = $Factory->createChild([ 'shipping_type' => $Type->getType() ]); diff --git a/ajax/backend/deactivate.php b/ajax/backend/deactivate.php index 47a959b..7058c82 100644 --- a/ajax/backend/deactivate.php +++ b/ajax/backend/deactivate.php @@ -4,7 +4,7 @@ * This file contains package_quiqqer_shipping_ajax_backend_deactivate */ -use \QUI\ERP\Shipping\Types\Factory; +use QUI\ERP\Shipping\Types\Factory; /** * Deactivate a shipping @@ -15,7 +15,7 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_deactivate', function ($shippingId) { - $factory = new Factory(); + $factory = new Factory(); $Shipping = $factory->getChild($shippingId); $Shipping->deactivate(); diff --git a/ajax/backend/getShippingList.php b/ajax/backend/getShippingList.php index 1946fb5..b0a9d72 100644 --- a/ajax/backend/getShippingList.php +++ b/ajax/backend/getShippingList.php @@ -16,7 +16,7 @@ 'package_quiqqer_shipping_ajax_backend_getShippingList', function () { $shippingEntries = Shipping::getInstance()->getShippingList(); - $result = []; + $result = []; foreach ($shippingEntries as $ShippingEntry) { /* @var $ShippingEntry ShippingEntry */ @@ -25,7 +25,7 @@ function () { $current = QUI::getLocale()->getCurrent(); - \usort($result, function ($a, $b) use ($current) { + usort($result, function ($a, $b) use ($current) { $aTitle = $a['title'][$current]; $bTitle = $b['title'][$current]; diff --git a/ajax/backend/rules/create.php b/ajax/backend/rules/create.php index fa9677f..a621ad7 100644 --- a/ajax/backend/rules/create.php +++ b/ajax/backend/rules/create.php @@ -4,7 +4,7 @@ * This file contains package_quiqqer_shipping_ajax_backend_create */ -use \QUI\ERP\Shipping\Rules\Factory; +use QUI\ERP\Shipping\Rules\Factory; /** @@ -15,9 +15,9 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_rules_create', function ($rules) { - $rules = \json_decode($rules, true); + $rules = json_decode($rules, true); $Factory = new Factory(); - $Rule = $Factory->createChild($rules); + $Rule = $Factory->createChild($rules); return $Rule->getId(); }, diff --git a/ajax/backend/rules/delete.php b/ajax/backend/rules/delete.php index 6b3e3c2..5ae2d9c 100644 --- a/ajax/backend/rules/delete.php +++ b/ajax/backend/rules/delete.php @@ -5,7 +5,6 @@ */ use QUI\ERP\Shipping\Rules\Factory; -use QUI\ExceptionStack; /** * Delete the shipping rule(s) @@ -15,10 +14,10 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_rules_delete', function ($ruleIds) { - $ruleIds = \json_decode($ruleIds, true); + $ruleIds = json_decode($ruleIds, true); $Factory = new Factory(); - if (!\is_array($ruleIds)) { + if (!is_array($ruleIds)) { $ruleIds = [$ruleIds]; } diff --git a/ajax/backend/rules/getList.php b/ajax/backend/rules/getList.php index b477d8b..c0a319d 100644 --- a/ajax/backend/rules/getList.php +++ b/ajax/backend/rules/getList.php @@ -14,7 +14,7 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_rules_getList', function ($options) { - $options = \json_decode($options, true); + $options = json_decode($options, true); if (!is_array($options)) { $options = []; @@ -44,8 +44,8 @@ function ($options) { } $Factory = QUI\ERP\Shipping\Rules\Factory::getInstance(); - $Grid = new Grid(); - $query = $Grid->parseDBParams($options); + $Grid = new Grid(); + $query = $Grid->parseDBParams($options); if (!isset($query['order'])) { $query['order'] = 'priority DESC'; @@ -68,8 +68,8 @@ function ($options) { $count = $Factory->countChildren($query); return [ - 'data' => $result, - 'page' => (int)$options['page'], + 'data' => $result, + 'page' => (int)$options['page'], 'total' => $count ]; }, diff --git a/ajax/backend/rules/getRules.php b/ajax/backend/rules/getRules.php index 272662e..0d0b734 100644 --- a/ajax/backend/rules/getRules.php +++ b/ajax/backend/rules/getRules.php @@ -12,12 +12,12 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_rules_getRules', function ($ruleIds) { - $ruleIds = \json_decode($ruleIds, true); - $Rules = QUI\ERP\Shipping\Rules\Factory::getInstance(); + $ruleIds = json_decode($ruleIds, true); + $Rules = QUI\ERP\Shipping\Rules\Factory::getInstance(); $result = []; - if (!\is_array($ruleIds)) { + if (!is_array($ruleIds)) { $ruleIds = []; } @@ -30,7 +30,7 @@ function ($ruleIds) { } // sort by priority - \usort($result, function ($a, $b) { + usort($result, function ($a, $b) { if (!isset($a['priority'])) { $a['priority'] = 0; } diff --git a/ajax/backend/rules/settings/getUnitFieldSetting.php b/ajax/backend/rules/settings/getUnitFieldSetting.php index d2512c4..78e0b87 100644 --- a/ajax/backend/rules/settings/getUnitFieldSetting.php +++ b/ajax/backend/rules/settings/getUnitFieldSetting.php @@ -14,9 +14,9 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_rules_settings_getUnitFieldSetting', function () { - $result = []; + $result = []; $Shipping = \QUI\ERP\Shipping\Shipping::getInstance(); - $ids = $Shipping->getShippingRuleUnitFieldIds(); + $ids = $Shipping->getShippingRuleUnitFieldIds(); foreach ($ids as $id) { try { diff --git a/ajax/backend/rules/update.php b/ajax/backend/rules/update.php index 41fac83..c0fdaca 100644 --- a/ajax/backend/rules/update.php +++ b/ajax/backend/rules/update.php @@ -4,7 +4,7 @@ * This file contains package_quiqqer_shipping_ajax_backend_rules_update */ -use \QUI\ERP\Shipping\Rules\Factory; +use QUI\ERP\Shipping\Rules\Factory; /** * Update a shipping method @@ -14,7 +14,7 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_rules_update', function ($ruleId, $data) { - $data = \json_decode($data, true); + $data = json_decode($data, true); $Factory = new Factory(); /* @var $Rule QUI\ERP\Shipping\Rules\ShippingRule */ diff --git a/ajax/backend/shippingStatus/getNotificationText.php b/ajax/backend/shippingStatus/getNotificationText.php index 0481fba..1fbd635 100644 --- a/ajax/backend/shippingStatus/getNotificationText.php +++ b/ajax/backend/shippingStatus/getNotificationText.php @@ -4,8 +4,8 @@ * This file contains package_quiqqer_shipping_ajax_backend_shippingStatus_getNotificationText */ -use QUI\ERP\Shipping\ShippingStatus\Handler; use QUI\ERP\Order\Handler as OrderHandler; +use QUI\ERP\Shipping\ShippingStatus\Handler; /** * Get status change notification text for a specific order diff --git a/ajax/backend/shippingStatus/list.php b/ajax/backend/shippingStatus/list.php index 0c2c0ba..9f8d1fb 100644 --- a/ajax/backend/shippingStatus/list.php +++ b/ajax/backend/shippingStatus/list.php @@ -14,16 +14,16 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_shippingStatus_list', function () { - $Grid = new QUI\Utils\Grid(); + $Grid = new QUI\Utils\Grid(); $Handler = Handler::getInstance(); - $list = $Handler->getShippingStatusList(); + $list = $Handler->getShippingStatusList(); $result = \array_map(function ($Status) { /* @var $Status \QUI\ERP\Shipping\ShippingStatus\Status */ return $Status->toArray(QUI::getLocale()); }, $list); - \usort($result, function ($a, $b) { + usort($result, function ($a, $b) { if ($a['id'] == $b['id']) { return 0; } diff --git a/ajax/backend/shippingStatus/update.php b/ajax/backend/shippingStatus/update.php index 1d447c8..43ba7dd 100644 --- a/ajax/backend/shippingStatus/update.php +++ b/ajax/backend/shippingStatus/update.php @@ -18,7 +18,7 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_shippingStatus_update', function ($id, $color, $title, $notification) { - $id = (int)$id; + $id = (int)$id; $Handler = Handler::getInstance(); $Handler->updateShippingStatus( diff --git a/ajax/backend/update.php b/ajax/backend/update.php index 8eba454..eb5f371 100644 --- a/ajax/backend/update.php +++ b/ajax/backend/update.php @@ -15,7 +15,7 @@ QUI::$Ajax->registerFunction( 'package_quiqqer_shipping_ajax_backend_update', function ($shippingId, $data) { - $Factory = new Factory(); + $Factory = new Factory(); $ShippingEntry = $Factory->getChild($shippingId); $data = \json_decode($data, true); diff --git a/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php b/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php index fb5cecf..9959f5b 100644 --- a/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php +++ b/src/QUI/ERP/Shipping/Api/AbstractShippingEntry.php @@ -102,9 +102,9 @@ abstract public function getWorkingTitle(); */ public function getIcon() { - return QUI\ERP\Shipping\Shipping::getInstance()->getHost(). - URL_OPT_DIR - .'quiqqer/shipping/bin/images/shipping/default.png'; + return QUI\ERP\Shipping\Shipping::getInstance()->getHost() . + URL_OPT_DIR + . 'quiqqer/shipping/bin/images/shipping/default.png'; } /** @@ -115,8 +115,8 @@ public function getIcon() public function toArray() { return [ - 'name' => $this->getName(), - 'title' => $this->getTitle(), + 'name' => $this->getName(), + 'title' => $this->getTitle(), 'description' => $this->getDescription() ]; } diff --git a/src/QUI/ERP/Shipping/Api/AbstractShippingProvider.php b/src/QUI/ERP/Shipping/Api/AbstractShippingProvider.php index 79c2e98..3acc495 100644 --- a/src/QUI/ERP/Shipping/Api/AbstractShippingProvider.php +++ b/src/QUI/ERP/Shipping/Api/AbstractShippingProvider.php @@ -6,8 +6,6 @@ namespace QUI\ERP\Shipping\Api; -use QUI; - /** * Shipping provider * diff --git a/src/QUI/ERP/Shipping/Api/AbstractShippingType.php b/src/QUI/ERP/Shipping/Api/AbstractShippingType.php index 80fdd63..5ab7e53 100644 --- a/src/QUI/ERP/Shipping/Api/AbstractShippingType.php +++ b/src/QUI/ERP/Shipping/Api/AbstractShippingType.php @@ -36,7 +36,7 @@ public function toArray($Locale = null) return [ 'title' => $this->getTitle($Locale), - 'type' => $this->getType() + 'type' => $this->getType() ]; } diff --git a/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php b/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php index 2b7d657..dbdde94 100644 --- a/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php +++ b/src/QUI/ERP/Shipping/Methods/Digital/ShippingType.php @@ -5,8 +5,8 @@ use QUI; use QUI\ERP\Areas\Utils as AreaUtils; use QUI\ERP\Products\Handler\Products; -use QUI\ERP\Shipping\Debug; use QUI\ERP\Products\Product\Types\DigitalProduct; +use QUI\ERP\Shipping\Debug; /** * Class DigitalType @@ -33,9 +33,9 @@ public function getTitle($Locale = null) */ public function getIcon() { - return QUI\ERP\Shipping\Shipping::getInstance()->getHost(). - URL_OPT_DIR - .'quiqqer/shipping/bin/images/shipping/download.png'; + return QUI\ERP\Shipping\Shipping::getInstance()->getHost() . + URL_OPT_DIR + . 'quiqqer/shipping/bin/images/shipping/download.png'; } /** @@ -72,7 +72,7 @@ public function canUsedInOrder( if (!($Product instanceof DigitalProduct)) { Debug::addLog( "{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: contains at least one NON-DIGITAL" - ." product that must be shipped physically." + . " product that must be shipped physically." ); return false; @@ -83,7 +83,7 @@ public function canUsedInOrder( } // Check restriction to certain products / product categories - $articles = $ShippingEntry->getAttribute('articles'); + $articles = $ShippingEntry->getAttribute('articles'); $categories = $ShippingEntry->getAttribute('categories'); $toInt = function ($article) { @@ -109,7 +109,7 @@ public function canUsedInOrder( return true; } - $ArticleList = $Order->getArticles(); + $ArticleList = $Order->getArticles(); $orderArticles = $ArticleList->getArticles(); foreach ($orderArticles as $Article) { @@ -117,13 +117,15 @@ public function canUsedInOrder( $productId = $Article->getId(); if (!empty($articles) && \in_array($productId, $articles)) { - Debug::addLog("{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: product {$productId} is in allowed list [ok]"); + Debug::addLog( + "{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: product {$productId} is in allowed list [ok]" + ); return true; } if (\is_array($categories)) { - $Product = QUI\ERP\Products\Handler\Products::getProduct($productId); + $Product = QUI\ERP\Products\Handler\Products::getProduct($productId); $articleCategories = $Product->getCategories(); /* @var $Category QUI\ERP\Products\Category\Category */ @@ -131,7 +133,9 @@ public function canUsedInOrder( $categoryId = $Category->getId(); if (\in_array($categoryId, $categories)) { - Debug::addLog("{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: category {$categoryId} is in allowed list [ok]"); + Debug::addLog( + "{$this->getTitle()} :: {$ShippingEntry->getTitle()} :: category {$categoryId} is in allowed list [ok]" + ); return true; } @@ -173,7 +177,7 @@ public function canUsedBy( // assignment $userGroupValue = $ShippingEntry->getAttribute('user_groups'); - $areasValue = $ShippingEntry->getAttribute('areas'); + $areasValue = $ShippingEntry->getAttribute('areas'); // if groups and areas are empty, everybody is allowed if (empty($userGroupValue) && empty($areasValue)) { @@ -202,7 +206,7 @@ public function canUsedBy( $ShippingEntry->getAttribute('user_groups') ); - $discountUsers = $userGroups['users']; + $discountUsers = $userGroups['users']; $discountGroups = $userGroups['groups']; if (empty($discountUsers) && empty($discountGroups)) { diff --git a/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php b/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php index e9c1027..3096d54 100644 --- a/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php +++ b/src/QUI/ERP/Shipping/Methods/Standard/ShippingType.php @@ -101,7 +101,7 @@ public function canUsedInOrder( } // assignment - $articles = $ShippingEntry->getAttribute('articles'); + $articles = $ShippingEntry->getAttribute('articles'); $categories = $ShippingEntry->getAttribute('categories'); $toInt = function ($article) { @@ -127,7 +127,7 @@ public function canUsedInOrder( return true; } - $ArticleList = $Order->getArticles(); + $ArticleList = $Order->getArticles(); $orderArticles = $ArticleList->getArticles(); foreach ($orderArticles as $Article) { @@ -143,7 +143,7 @@ public function canUsedInOrder( } if (is_array($categories)) { - $Product = QUI\ERP\Products\Handler\Products::getProduct($productId); + $Product = QUI\ERP\Products\Handler\Products::getProduct($productId); $articleCategories = $Product->getCategories(); /* @var $Category QUI\ERP\Products\Category\Category */ @@ -195,7 +195,7 @@ public function canUsedBy( // assignment $userGroupValue = $ShippingEntry->getAttribute('user_groups'); - $areasValue = $ShippingEntry->getAttribute('areas'); + $areasValue = $ShippingEntry->getAttribute('areas'); // if groups and areas are empty, everybody is allowed if (empty($userGroupValue) && empty($areasValue)) { @@ -224,7 +224,7 @@ public function canUsedBy( $ShippingEntry->getAttribute('user_groups') ); - $discountUsers = $userGroups['users']; + $discountUsers = $userGroups['users']; $discountGroups = $userGroups['groups']; if (empty($discountUsers) && empty($discountGroups)) { diff --git a/src/QUI/ERP/Shipping/Methods/Standard/___Shipping.php b/src/QUI/ERP/Shipping/Methods/Standard/___Shipping.php deleted file mode 100644 index c68f98a..0000000 --- a/src/QUI/ERP/Shipping/Methods/Standard/___Shipping.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/** - * This file contains QUI\ERP\Shipping\Methods\Standard\Shipping - */ - -namespace QUI\ERP\Shipping\Methods\Standard; - -use QUI; -use QUI\ERP\Shipping\Shipping as ShippingHandler; - -/** - * Class Shipping - * - * @package QUI\ERP\Shipping\Methods\Standard\Shipping - */ -class Shipping extends QUI\ERP\Shipping\Api\AbstractShippingEntry -{ - /** - * @return array|string - */ - public function getTitle() - { - return $this->getLocale()->get('quiqqer/shipping', 'shipping.standard.title'); - } - - /** - * @return array|string - */ - public function getWorkingTitle() - { - return $this->getLocale()->get('quiqqer/shipping', 'shipping.standard.workingTitle'); - } - - /** - * @return array|string - */ - public function getDescription() - { - return $this->getLocale()->get('quiqqer/shipping', 'shipping.standard.description'); - } - - /** - * Return the shipping icon (the URL path) - * Can be overwritten - * - * @return string - */ - public function getIcon() - { - return ShippingHandler::getInstance()->getHost(). - URL_OPT_DIR. - 'quiqqer/shipping/bin/shipping/standard.png'; - } -} diff --git a/src/QUI/ERP/Shipping/Order/ShippingAddress.php b/src/QUI/ERP/Shipping/Order/ShippingAddress.php index 9bedfb5..ee81fad 100644 --- a/src/QUI/ERP/Shipping/Order/ShippingAddress.php +++ b/src/QUI/ERP/Shipping/Order/ShippingAddress.php @@ -24,7 +24,7 @@ public function __construct($attributes = []) { parent::__construct($attributes); - $this->addCSSFile(\dirname(__FILE__).'/ShippingAddress.css'); + $this->addCSSFile(\dirname(__FILE__) . '/ShippingAddress.css'); $this->addCSSClass('quiqqer-shipping-address'); } @@ -54,7 +54,7 @@ public function getBody() try { $Project = QUI::getRewrite()->getProject(); - $sites = $Project->getSites([ + $sites = $Project->getSites([ 'where' => [ 'type' => 'quiqqer/frontend-users:types/profile' ], @@ -63,7 +63,7 @@ public function getBody() if (isset($sites[0])) { /* @var $Profile QUI\Projects\Site */ - $Profile = $sites[0]; + $Profile = $sites[0]; $profileLink = $Profile->getUrlRewritten(); $profileLink .= '/user/address'; } @@ -72,9 +72,9 @@ public function getBody() } // current address - $currentAddress = ''; + $currentAddress = ''; $ShippingAddress = null; - + $Shipping = QUI\ERP\Shipping\Shipping::getInstance()->getShippingByObject($Order); if ($Shipping) { @@ -88,11 +88,11 @@ public function getBody() } $Engine->assign([ - 'addressList' => $addressList, - 'profileLink' => $profileLink, + 'addressList' => $addressList, + 'profileLink' => $profileLink, 'currentAddress' => $currentAddress ]); - return $Engine->fetch(\dirname(__FILE__).'/ShippingAddress.html'); + return $Engine->fetch(\dirname(__FILE__) . '/ShippingAddress.html'); } } -- GitLab