diff --git a/Classes/Controller/ProductController.php b/Classes/Controller/ProductController.php index 3de9b150..5364ce83 100644 --- a/Classes/Controller/ProductController.php +++ b/Classes/Controller/ProductController.php @@ -82,8 +82,8 @@ protected function createDemandObjectFromSettings(array $settings): ProductDeman } if ($settings['orderBy']) { if ( - !isset($settings['orderDirection']) && - $settings['orderDirection'] !== 'DESC' + !isset($settings['orderDirection']) + && $settings['orderDirection'] !== 'DESC' ) { $settings['orderDirection'] = 'ASC'; } diff --git a/Classes/Domain/Model/Product/BeVariant.php b/Classes/Domain/Model/Product/BeVariant.php index 1be98ef3..ca7e7242 100644 --- a/Classes/Domain/Model/Product/BeVariant.php +++ b/Classes/Domain/Model/Product/BeVariant.php @@ -98,8 +98,8 @@ public function getPriceCalculated(): float }; if ( - isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) && - is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) + isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) + && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) ) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount'] as $funcRef) { if ($funcRef) { @@ -144,8 +144,8 @@ public function getBestPriceCalculated($frontendUserGroupIds = []): float }; if ( - isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) && - is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) + isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) + && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) ) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount'] as $funcRef) { if ($funcRef) { @@ -226,8 +226,8 @@ public function getBestSpecialPrice(array $frontendUserGroupIds = []): ?SpecialP foreach ($this->getSpecialPrices() as $specialPrice) { if ($bestSpecialPrice === null) { - if (!$specialPrice->getFrontendUserGroup() || - in_array($specialPrice->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) + if (!$specialPrice->getFrontendUserGroup() + || in_array($specialPrice->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) ) { $bestSpecialPrice = $specialPrice; } @@ -236,16 +236,16 @@ public function getBestSpecialPrice(array $frontendUserGroupIds = []): ?SpecialP if ( ( - ($specialPrice->getPrice() < $bestSpecialPrice->getPrice()) && - in_array($this->priceCalcMethod, [0, 1, 4, 5]) - ) || - ( - ($specialPrice->getPrice() > $bestSpecialPrice->getPrice()) && - in_array($this->priceCalcMethod, [2, 3]) + ($specialPrice->getPrice() < $bestSpecialPrice->getPrice()) + && in_array($this->priceCalcMethod, [0, 1, 4, 5]) + ) + || ( + ($specialPrice->getPrice() > $bestSpecialPrice->getPrice()) + && in_array($this->priceCalcMethod, [2, 3]) ) ) { - if (!$specialPrice->getFrontendUserGroup() || - in_array($specialPrice->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) + if (!$specialPrice->getFrontendUserGroup() + || in_array($specialPrice->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) ) { $bestSpecialPrice = $specialPrice; } @@ -263,12 +263,12 @@ public function getBestPrice(array $frontendUserGroupIds = []): float if ($bestSpecialPrice) { if ( ( - ($bestSpecialPrice->getPrice() < $bestPrice) && - in_array($this->priceCalcMethod, [0, 1, 4, 5]) - ) || - ( - ($bestSpecialPrice->getPrice() > $bestPrice) && - in_array($this->priceCalcMethod, [2, 3]) + ($bestSpecialPrice->getPrice() < $bestPrice) + && in_array($this->priceCalcMethod, [0, 1, 4, 5]) + ) + || ( + ($bestSpecialPrice->getPrice() > $bestPrice) + && in_array($this->priceCalcMethod, [2, 3]) ) ) { $bestPrice = $bestSpecialPrice->getPrice(); @@ -301,9 +301,9 @@ public function getBasePrice(): ?float { //TODO: respects different measuring units between variant and product if ( - !$this->product || - !$this->product->getIsMeasureUnitCompatibility() || - !$this->getPriceMeasure() > 0 + !$this->product + || !$this->product->getIsMeasureUnitCompatibility() + || !$this->getPriceMeasure() > 0 ) { return null; } @@ -424,20 +424,20 @@ public function getTitle(): string $titleArray = []; if ($this->getProduct()->getBeVariantAttribute1()) { - $titleArray[] = - $this->getProduct()->getBeVariantAttribute1()->getTitle() + $titleArray[] + = $this->getProduct()->getBeVariantAttribute1()->getTitle() . ' ' . $this->getBeVariantAttributeOption1()->getTitle(); } if ($this->getProduct()->getBeVariantAttribute2()) { - $titleArray[] = - $this->getProduct()->getBeVariantAttribute2()->getTitle() + $titleArray[] + = $this->getProduct()->getBeVariantAttribute2()->getTitle() . ' ' . $this->getBeVariantAttributeOption2()->getTitle(); } if ($this->getProduct()->getBeVariantAttribute3()) { - $titleArray[] = - $this->getProduct()->getBeVariantAttribute3()->getTitle() + $titleArray[] + = $this->getProduct()->getBeVariantAttribute3()->getTitle() . ' ' . $this->getBeVariantAttributeOption3()->getTitle(); } diff --git a/Classes/Domain/Model/Product/Product.php b/Classes/Domain/Model/Product/Product.php index 4b3f6244..cde5ac71 100644 --- a/Classes/Domain/Model/Product/Product.php +++ b/Classes/Domain/Model/Product/Product.php @@ -194,8 +194,8 @@ public function getBestSpecialPrice(array $frontendUserGroupIds = []): float foreach ($this->specialPrices as $specialPrice) { if ($specialPrice->getPrice() < $bestSpecialPrice) { if ( - !$specialPrice->getFrontendUserGroup() || - in_array($specialPrice->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) + !$specialPrice->getFrontendUserGroup() + || in_array($specialPrice->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) ) { $bestSpecialPrice = $specialPrice->getPrice(); } @@ -238,8 +238,8 @@ public function getQuantityDiscountArray(array $frontendUserGroupIds = []): arra if ($this->getQuantityDiscounts()) { foreach ($this->getQuantityDiscounts() as $quantityDiscount) { - if (!$quantityDiscount->getFrontendUserGroup() || - in_array($quantityDiscount->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) + if (!$quantityDiscount->getFrontendUserGroup() + || in_array($quantityDiscount->getFrontendUserGroup()->getUid(), $frontendUserGroupIds) ) { $quantityDiscountArray[] = $quantityDiscount->toArray(); } diff --git a/Classes/Domain/Repository/CategoryRepository.php b/Classes/Domain/Repository/CategoryRepository.php index b4100a95..b1b5e3d8 100644 --- a/Classes/Domain/Repository/CategoryRepository.php +++ b/Classes/Domain/Repository/CategoryRepository.php @@ -31,8 +31,8 @@ public function findAllAsArray(?Category $selectedCategory = null): array $newCategory = [ 'uid' => $localCategory->getUid(), 'title' => $localCategory->getTitle(), - 'parent' => - ($localCategory->getParent() ? $localCategory->getParent()->getUid() : null), + 'parent' + => ($localCategory->getParent() ? $localCategory->getParent()->getUid() : null), 'subcategories' => null, 'isSelected' => ($selectedCategory === $localCategory), ]; @@ -47,8 +47,8 @@ public function findSubcategoriesRecursiveAsArray(?Category $parentCategory = nu $localCategories = $this->findAllAsArray(); foreach ($localCategories as $category) { if ( - !$parentCategory || - $category['uid'] === $parentCategory->getUid() + !$parentCategory + || $category['uid'] === $parentCategory->getUid() ) { $this->getSubcategoriesIds( $localCategories, @@ -83,8 +83,8 @@ protected function buildSubcategories(array $categoriesArray, array $parentCateg foreach ($categoriesArray as $category) { if ($category['parent'] === $parentCategory['uid']) { $newCategory = $category; - $newCategory['subcategories'] = - $this->buildSubcategories($categoriesArray, $category); + $newCategory['subcategories'] + = $this->buildSubcategories($categoriesArray, $category); $categories[] = $newCategory; } } diff --git a/Classes/Domain/Repository/Product/ProductRepository.php b/Classes/Domain/Repository/Product/ProductRepository.php index fd7f4fbc..a39e09cf 100644 --- a/Classes/Domain/Repository/Product/ProductRepository.php +++ b/Classes/Domain/Repository/Product/ProductRepository.php @@ -74,15 +74,15 @@ protected function createOrderingsFromDemand(ProductDemand $demand): array if (!empty($orderList)) { foreach ($orderList as $orderItem) { - [$orderField, $orderDirection] = - array_pad( + [$orderField, $orderDirection] + = array_pad( GeneralUtility::trimExplode(' ', $orderItem, true), 2, 'asc' ); if ( - $orderDirection && - strtolower($orderDirection) === 'desc' + $orderDirection + && strtolower($orderDirection) === 'desc' ) { $orderings[$orderField] = QueryInterface::ORDER_DESCENDING; } else { diff --git a/Classes/EventListener/CheckProductAvailability.php b/Classes/EventListener/CheckProductAvailability.php index 0da263a5..9dad356d 100644 --- a/Classes/EventListener/CheckProductAvailability.php +++ b/Classes/EventListener/CheckProductAvailability.php @@ -93,9 +93,9 @@ public function checkStockForBeVariant(CartProductBeVariant $cartProductBeVarian } if ( - $mode === 'add' && - $cart->getProductById($cartProduct->getId()) && - $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId()) + $mode === 'add' + && $cart->getProductById($cartProduct->getId()) + && $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId()) ) { $quantityInCart += $cart->getProductById($cartProduct->getId())->getBeVariantById($cartProductBeVariant->getId())->getQuantity(); } diff --git a/Classes/EventListener/Create/CheckRequest.php b/Classes/EventListener/Create/CheckRequest.php index 7a9e7e61..67cd84d0 100644 --- a/Classes/EventListener/Create/CheckRequest.php +++ b/Classes/EventListener/Create/CheckRequest.php @@ -22,8 +22,8 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void $request = $event->getRequest(); if ( - !$request->hasArgument('product') || - !(int)$request->getArgument('product') + !$request->hasArgument('product') + || !(int)$request->getArgument('product') ) { $event->addError( new FlashMessage( @@ -39,8 +39,8 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void } if ( - !$request->hasArgument('quantity') || - $request->getArgument('quantity') < 0 + !$request->hasArgument('quantity') + || $request->getArgument('quantity') < 0 ) { $event->addError( new FlashMessage( diff --git a/Classes/Hooks/DatamapDataHandlerHook.php b/Classes/Hooks/DatamapDataHandlerHook.php index 734aaec8..c2c990c0 100644 --- a/Classes/Hooks/DatamapDataHandlerHook.php +++ b/Classes/Hooks/DatamapDataHandlerHook.php @@ -96,11 +96,11 @@ protected function isAllowedTargetPage($listType, $doktype) ($doktype === 183) && ( $listType === 'cartproducts_singleproduct' ) - ) || - ( + ) + || ( ($doktype !== 183) && ( - $listType === 'cartproducts_products' || - $listType === 'cartproducts_slots' + $listType === 'cartproducts_products' + || $listType === 'cartproducts_slots' ) ) ) { diff --git a/Classes/Updates/SwitchableControllerActionsPluginUpdater.php b/Classes/Updates/SwitchableControllerActionsPluginUpdater.php index e4ba34a9..396f172f 100644 --- a/Classes/Updates/SwitchableControllerActionsPluginUpdater.php +++ b/Classes/Updates/SwitchableControllerActionsPluginUpdater.php @@ -153,8 +153,8 @@ protected function getMigrationRecords(): array protected function getTargetListType(string $sourceListType, string $switchableControllerActions): string { foreach (self::MIGRATION_SETTINGS as $setting) { - if ($setting['sourceListType'] === $sourceListType && - $setting['switchableControllerActions'] === $switchableControllerActions + if ($setting['sourceListType'] === $sourceListType + && $setting['switchableControllerActions'] === $switchableControllerActions ) { return $setting['targetListType']; } diff --git a/Classes/ViewHelpers/CanonicalTagViewHelper.php b/Classes/ViewHelpers/CanonicalTagViewHelper.php index a48c5ccc..cde73d46 100644 --- a/Classes/ViewHelpers/CanonicalTagViewHelper.php +++ b/Classes/ViewHelpers/CanonicalTagViewHelper.php @@ -54,8 +54,8 @@ public function render(): string } $arguments = [ - ['tx_cartproducts_product' => - [ + ['tx_cartproducts_product' + => [ 'controller' => 'Product', 'product' => $product->getUid(), ], diff --git a/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php b/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php index c9609631..6c4513eb 100644 --- a/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php +++ b/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php @@ -21,9 +21,9 @@ // prepend category restriction at the beginning of foreign_table_where if (!empty($categoryRestriction)) { - $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['category']['config']['foreign_table_where'] = $categoryRestriction . - $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['category']['config']['foreign_table_where']; - $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['categories']['config']['foreign_table_where'] = $categoryRestriction . - $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['categories']['config']['foreign_table_where']; + $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['category']['config']['foreign_table_where'] = $categoryRestriction + . $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['category']['config']['foreign_table_where']; + $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['categories']['config']['foreign_table_where'] = $categoryRestriction + . $GLOBALS['TCA']['tx_cartproducts_domain_model_product_product']['columns']['categories']['config']['foreign_table_where']; } } diff --git a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php index 9fffc9cf..3ad1d05e 100644 --- a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php +++ b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php @@ -140,10 +140,10 @@ ['label' => '', 'value' => 0], ], 'foreign_table' => 'tx_cartproducts_domain_model_product_bevariantattributeoption', - 'foreign_table_where' => - ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' . - ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cartproducts_domain_model_product_product.be_variant_attribute1 FROM tx_cartproducts_domain_model_product_product WHERE tx_cartproducts_domain_model_product_product.uid=###REC_FIELD_product###)) ' . - ' ORDER BY tx_cartproducts_domain_model_product_bevariantattributeoption.title ', + 'foreign_table_where' + => ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' + . ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cartproducts_domain_model_product_product.be_variant_attribute1 FROM tx_cartproducts_domain_model_product_product WHERE tx_cartproducts_domain_model_product_product.uid=###REC_FIELD_product###)) ' + . ' ORDER BY tx_cartproducts_domain_model_product_bevariantattributeoption.title ', 'minitems' => 0, 'maxitems' => 1, 'eval' => 'int', @@ -161,10 +161,10 @@ ['label' => '', 'value' => 0], ], 'foreign_table' => 'tx_cartproducts_domain_model_product_bevariantattributeoption', - 'foreign_table_where' => - ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' . - ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cartproducts_domain_model_product_product.be_variant_attribute2 FROM tx_cartproducts_domain_model_product_product WHERE tx_cartproducts_domain_model_product_product.uid=###REC_FIELD_product###)) ' . - ' ORDER BY tx_cartproducts_domain_model_product_bevariantattributeoption.title ', + 'foreign_table_where' + => ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' + . ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cartproducts_domain_model_product_product.be_variant_attribute2 FROM tx_cartproducts_domain_model_product_product WHERE tx_cartproducts_domain_model_product_product.uid=###REC_FIELD_product###)) ' + . ' ORDER BY tx_cartproducts_domain_model_product_bevariantattributeoption.title ', 'minitems' => 0, 'maxitems' => 1, 'eval' => 'int', @@ -182,10 +182,10 @@ ['label' => '', 'value' => 0], ], 'foreign_table' => 'tx_cartproducts_domain_model_product_bevariantattributeoption', - 'foreign_table_where' => - ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' . - ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cartproducts_domain_model_product_product.be_variant_attribute3 FROM tx_cartproducts_domain_model_product_product WHERE tx_cartproducts_domain_model_product_product.uid=###REC_FIELD_product###)) ' . - ' ORDER BY tx_cartproducts_domain_model_product_bevariantattributeoption.title ', + 'foreign_table_where' + => ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.pid=###CURRENT_PID###' + . ' AND tx_cartproducts_domain_model_product_bevariantattributeoption.be_variant_attribute IN ((SELECT tx_cartproducts_domain_model_product_product.be_variant_attribute3 FROM tx_cartproducts_domain_model_product_product WHERE tx_cartproducts_domain_model_product_product.uid=###REC_FIELD_product###)) ' + . ' ORDER BY tx_cartproducts_domain_model_product_bevariantattributeoption.title ', 'minitems' => 0, 'maxitems' => 1, 'eval' => 'int', diff --git a/Documentation/Changelog/5.0/Feature-145-DisplayAvailableStock.rst b/Documentation/Changelog/5.0/Feature-145-DisplayAvailableStock.rst index 0687c601..9cc64276 100644 --- a/Documentation/Changelog/5.0/Feature-145-DisplayAvailableStock.rst +++ b/Documentation/Changelog/5.0/Feature-145-DisplayAvailableStock.rst @@ -1,4 +1,4 @@ -.. include:: ../../Includes.txt +.. include:: ../../Includes.rst.txt ======================================== Breaking: #145 - Display available stock diff --git a/Tests/Unit/Domain/Model/CategoryTest.php b/Tests/Unit/Domain/Model/CategoryTest.php index 663fe5dc..5429ad07 100644 --- a/Tests/Unit/Domain/Model/CategoryTest.php +++ b/Tests/Unit/Domain/Model/CategoryTest.php @@ -69,7 +69,7 @@ public function getCartProductShowPidReturnsShowPid(): void */ protected function getAccessibleMock( string $originalClassName, - array|null $methods = [], + ?array $methods = [], array $arguments = [], string $mockClassName = '', bool $callOriginalConstructor = true, diff --git a/ext_localconf.php b/ext_localconf.php index 6ac2d317..cd0afceb 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -76,13 +76,13 @@ // processDatamapClass Hook -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['cartproducts_allowed'] = - DatamapDataHandlerHook::class; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['cartproducts_allowed'] + = DatamapDataHandlerHook::class; // clearCachePostProc Hook -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['cartproducts_clearcache'] = - DataHandler::class . '->clearCachePostProc'; +$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['cartproducts_clearcache'] + = DataHandler::class . '->clearCachePostProc'; // register "cartproducts:" namespace $GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['cartproducts'][]