From 25b4b7f425f4db74923f0dc1dcb2ee401eb7170f Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Tue, 20 Aug 2024 15:47:28 +0200 Subject: [PATCH 01/11] [PayumBundle] support 2.5 and dev-master --- .../ReplyToSymfonyResponseConverter.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php index 1ecb0f26f1..8c6bff0c12 100644 --- a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php +++ b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php @@ -18,12 +18,30 @@ namespace CoreShop\Bundle\PayumBundle\Exception; -use Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter as BaseReplyToSymfonyResponseConverter; use Payum\Core\Reply\ReplyInterface; +use Symfony\Component\HttpFoundation\Response; -class ReplyToSymfonyResponseConverter extends BaseReplyToSymfonyResponseConverter +if (false) { + //This is just for the IDE + class BaseCoreShopReplayToSymfonyResponseConverter { + public function convert(ReplyInterface $reply): Response {} + } +} + + +if (class_exists('Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter')) { + \class_alias(\Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter'); +} +else if (class_exists('Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter')) { + \class_alias(\Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter'); +} +else { + throw new \Exception('Cannot find Payum ReplyToSymfonyResponseConverter class'); +} + +class ReplyToSymfonyResponseConverter extends BaseCoreShopReplayToSymfonyResponseConverter { - public function convert(ReplyInterface $reply) + public function convert(ReplyInterface $reply): Response { if ($reply instanceof ReplyException && null !== $reply->getPrevious()) { throw $reply->getPrevious(); From 31d4c998161fb99dc388ae3821f6f17346b3db5c Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Wed, 21 Aug 2024 07:54:55 +0200 Subject: [PATCH 02/11] [PayumBundle] support 2.5 and dev-master --- .../Exception/ReplyToSymfonyResponseConverter.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php index 8c6bff0c12..194be6ff50 100644 --- a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php +++ b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php @@ -24,7 +24,9 @@ if (false) { //This is just for the IDE class BaseCoreShopReplayToSymfonyResponseConverter { - public function convert(ReplyInterface $reply): Response {} + public function convert(ReplyInterface $reply): Response { + throw new \RuntimeException('Not implemented'); + } } } @@ -32,11 +34,11 @@ public function convert(ReplyInterface $reply): Response {} if (class_exists('Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter')) { \class_alias(\Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter'); } -else if (class_exists('Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter')) { +elseif (class_exists('Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter')) { \class_alias(\Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter'); } else { - throw new \Exception('Cannot find Payum ReplyToSymfonyResponseConverter class'); + throw new \RuntimeException('Cannot find Payum ReplyToSymfonyResponseConverter class'); } class ReplyToSymfonyResponseConverter extends BaseCoreShopReplayToSymfonyResponseConverter From 3ca2d1283bda70c020d4333525c3d4b221d1fb76 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Wed, 21 Aug 2024 08:07:01 +0200 Subject: [PATCH 03/11] [PayumBundle] support 2.5 and dev-master --- .../PayumBundle/Exception/ReplyToSymfonyResponseConverter.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php index 194be6ff50..2f248b3055 100644 --- a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php +++ b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php @@ -21,6 +21,9 @@ use Payum\Core\Reply\ReplyInterface; use Symfony\Component\HttpFoundation\Response; +/** + * @psalm-suppress TypeDoesNotContainType + */ if (false) { //This is just for the IDE class BaseCoreShopReplayToSymfonyResponseConverter { From 51fe2649b114435fc9e010fe0c758a2f7acc669e Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Wed, 21 Aug 2024 16:15:45 +0200 Subject: [PATCH 04/11] [InventoryBundle] add stock label renderer and hide onHand field --- .../CoreShopProduct.json | 258 ++++++++++-------- .../Pimcore/Renderer/StockOnHandRenderer.php | 40 +++ .../Resources/config/services.yml | 4 + .../views/pimcore/stock_text.html.twig | 9 + 4 files changed, 203 insertions(+), 108 deletions(-) create mode 100644 src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php create mode 100644 src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig diff --git a/src/CoreShop/Bundle/CoreBundle/Resources/install/pimcore/classes/CoreShopProductBundle/CoreShopProduct.json b/src/CoreShop/Bundle/CoreBundle/Resources/install/pimcore/classes/CoreShopProductBundle/CoreShopProduct.json index ee3f54dd6d..1b70172b83 100644 --- a/src/CoreShop/Bundle/CoreBundle/Resources/install/pimcore/classes/CoreShopProductBundle/CoreShopProduct.json +++ b/src/CoreShop/Bundle/CoreBundle/Resources/install/pimcore/classes/CoreShopProductBundle/CoreShopProduct.json @@ -652,110 +652,147 @@ "locked": false }, { - "fieldtype": "panel", - "labelWidth": 165, - "layout": null, "name": "stock", "type": null, "region": null, "title": "coreshop.product.stock", - "width": null, - "height": null, + "width": "", + "height": "", "collapsible": false, "collapsed": false, "bodyStyle": "", "datatype": "layout", "permissions": null, - "childs": [ + "children": [ { - "fieldtype": "numeric", - "width": "", - "defaultValue": null, - "integer": true, - "unsigned": false, - "minValue": null, - "maxValue": null, - "unique": false, - "decimalSize": null, - "decimalPrecision": null, - "name": "onHold", - "title": "coreshop.product.on_hold", - "tooltip": "", - "mandatory": false, - "noteditable": true, - "index": false, - "locked": false, - "style": "", - "permissions": null, - "datatype": "data", - "relationType": false, - "invisible": false, - "visibleGridView": false, - "visibleSearch": false - }, - { - "fieldtype": "numeric", + "name": "stock", + "type": null, + "region": null, + "title": "coreshop.product.stock", "width": "", - "defaultValue": null, - "integer": true, - "unsigned": false, - "minValue": null, - "maxValue": null, - "unique": false, - "decimalSize": null, - "decimalPrecision": null, - "name": "onHand", - "title": "coreshop.product.on_hand", - "tooltip": "", - "mandatory": false, - "noteditable": false, - "index": false, - "locked": false, - "style": "", + "height": "", + "collapsible": false, + "collapsed": false, + "bodyStyle": "", + "datatype": "layout", "permissions": null, - "datatype": "data", - "relationType": false, - "invisible": false, - "visibleGridView": false, - "visibleSearch": false - }, - { - "fieldtype": "booleanSelect", - "yesLabel": "isTracked", - "noLabel": "notTracked", - "emptyLabel": null, - "options": [ + "children": [ { - "key": "empty", - "value": 0 + "name": "stockOnHoldLabel", + "type": null, + "region": null, + "title": "", + "width": "", + "height": "", + "collapsible": false, + "collapsed": false, + "bodyStyle": "", + "datatype": "layout", + "permissions": null, + "children": [], + "locked": false, + "fieldtype": "text", + "html": "
", + "renderingClass": "@CoreShop\\Bundle\\InventoryBundle\\Pimcore\\Renderer\\StockOnHandRenderer", + "renderingData": "", + "border": false + }, + { + "name": "onHold", + "title": "coreshop.product.on_hold", + "tooltip": "", + "mandatory": false, + "noteditable": true, + "index": false, + "locked": false, + "style": "", + "permissions": null, + "datatype": "data", + "fieldtype": "numeric", + "relationType": false, + "invisible": true, + "visibleGridView": false, + "visibleSearch": false, + "width": "", + "defaultValue": null, + "integer": true, + "unsigned": false, + "minValue": null, + "maxValue": null, + "unique": false, + "decimalSize": null, + "decimalPrecision": null, + "defaultValueGenerator": "" }, { - "key": "isTracked", - "value": 1 + "name": "onHand", + "title": "coreshop.product.on_hand", + "tooltip": "", + "mandatory": false, + "noteditable": false, + "index": false, + "locked": false, + "style": "", + "permissions": null, + "datatype": "data", + "fieldtype": "numeric", + "relationType": false, + "invisible": false, + "visibleGridView": false, + "visibleSearch": false, + "width": "", + "defaultValue": null, + "integer": true, + "unsigned": false, + "minValue": null, + "maxValue": null, + "unique": false, + "decimalSize": null, + "decimalPrecision": null, + "defaultValueGenerator": "" }, { - "key": "notTracked", - "value": -1 + "name": "isTracked", + "title": "coreshop.product.is_tracked", + "tooltip": "", + "mandatory": false, + "noteditable": false, + "index": false, + "locked": false, + "style": "", + "permissions": null, + "datatype": "data", + "fieldtype": "booleanSelect", + "relationType": false, + "invisible": false, + "visibleGridView": false, + "visibleSearch": false, + "yesLabel": "isTracked", + "noLabel": "notTracked", + "emptyLabel": null, + "options": [ + { + "key": null, + "value": 0 + }, + { + "key": "isTracked", + "value": 1 + }, + { + "key": "notTracked", + "value": -1 + } + ], + "width": 0 } ], - "name": "isTracked", - "title": "coreshop.product.is_tracked", - "tooltip": "", - "mandatory": false, - "noteditable": false, - "index": false, "locked": false, - "style": "", - "permissions": null, - "datatype": "data", - "relationType": false, - "invisible": false, - "visibleGridView": false, - "visibleSearch": false + "fieldtype": "fieldset", + "labelWidth": 0, + "labelAlign": "left" }, { - "fieldtype": "fieldset", - "labelWidth": 150, "name": "quantity_restrictions", "type": null, "region": null, @@ -767,21 +804,8 @@ "bodyStyle": "", "datatype": "layout", "permissions": null, - "childs": [ + "children": [ { - "fieldtype": "numeric", - "width": "", - "defaultValue": 0, - "queryColumnType": "double", - "columnType": "double", - "phpdocType": "float", - "integer": true, - "unsigned": false, - "minValue": 0, - "maxValue": null, - "unique": false, - "decimalSize": 1, - "decimalPrecision": 1, "name": "minimumQuantityToOrder", "title": "coreshop.product.minimum_quantity_to_order", "tooltip": "", @@ -792,18 +816,13 @@ "style": "", "permissions": null, "datatype": "data", + "fieldtype": "numeric", "relationType": false, "invisible": false, "visibleGridView": false, - "visibleSearch": false - }, - { - "fieldtype": "numeric", + "visibleSearch": false, "width": "", - "defaultValue": null, - "queryColumnType": "double", - "columnType": "double", - "phpdocType": "float", + "defaultValue": 0, "integer": true, "unsigned": false, "minValue": 0, @@ -811,8 +830,11 @@ "unique": false, "decimalSize": 1, "decimalPrecision": 1, + "defaultValueGenerator": "" + }, + { "name": "maximumQuantityToOrder", - "title": "coreshop.product.maximal_quantity_to_order", + "title": "coreshop.product.maximum_quantity_to_order", "tooltip": "", "mandatory": false, "noteditable": false, @@ -821,16 +843,36 @@ "style": "", "permissions": null, "datatype": "data", + "fieldtype": "numeric", "relationType": false, "invisible": false, "visibleGridView": false, - "visibleSearch": false + "visibleSearch": false, + "width": "", + "defaultValue": null, + "integer": true, + "unsigned": false, + "minValue": 0, + "maxValue": null, + "unique": false, + "decimalSize": 1, + "decimalPrecision": 1, + "defaultValueGenerator": "" } ], - "locked": false + "locked": false, + "fieldtype": "fieldset", + "labelWidth": 150, + "labelAlign": "left" } ], - "locked": false + "locked": false, + "fieldtype": "panel", + "layout": null, + "border": false, + "icon": "", + "labelWidth": 165, + "labelAlign": "left" }, { "fieldtype": "panel", diff --git a/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php b/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php new file mode 100644 index 0000000000..69e921bf15 --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php @@ -0,0 +1,40 @@ +twig->render('@CoreShopInventory/pimcore/stock_text.html.twig', [ + 'stockable' => $object, + ]); + } +} diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml b/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml index 581d7b222b..c7d357bd5e 100755 --- a/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml @@ -20,3 +20,7 @@ services: - '@CoreShop\Component\Inventory\Checker\AvailabilityCheckerInterface' tags: - { name: twig.extension } + + CoreShop\Bundle\InventoryBundle\Pimcore\Renderer\StockOnHandRenderer: + arguments: + - '@twig' \ No newline at end of file diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig b/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig new file mode 100644 index 0000000000..fb877a5a7c --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig @@ -0,0 +1,9 @@ +{% if stockable.isTracked %} +
+ Available on Hand: {{ stockable.onHand ?: 0 }} / Reserved: {{ stockable.onHold ?: 0 }} +
+{% else %} +
+ Stock Tracking is disabled +
+{% endif %} \ No newline at end of file From a7896eed31d14218d203f53b5233d7813dd141c4 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 22 Aug 2024 07:58:19 +0200 Subject: [PATCH 05/11] [InventoryBundle] add translations for stock label --- .../InventoryBundle/Resources/translations/messages.de.yml | 6 ++++++ .../InventoryBundle/Resources/translations/messages.en.yml | 6 ++++++ .../Resources/views/pimcore/stock_text.html.twig | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.de.yml create mode 100644 src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.en.yml diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.de.yml b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.de.yml new file mode 100644 index 0000000000..d2ac590890 --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.de.yml @@ -0,0 +1,6 @@ +coreshop: + inventory: + stock: + on_hand: 'Verfügbare Lagerbestände: %on_hand%' + on_hold: 'Reservierte Lagerbestände: %on_hold%' + not_tracked: 'Lagerbestände nicht verfolgt' diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.en.yml b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.en.yml new file mode 100644 index 0000000000..60ca2cb7b5 --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.en.yml @@ -0,0 +1,6 @@ +coreshop: + inventory: + stock: + on_hand: 'Available Stock on Hand: %on_hand%' + on_hold: 'Reserved Stock: %on_hold%' + not_tracked: 'Stock not tracked' diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig b/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig index fb877a5a7c..ebff282407 100644 --- a/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig @@ -1,9 +1,9 @@ {% if stockable.isTracked %}
- Available on Hand: {{ stockable.onHand ?: 0 }} / Reserved: {{ stockable.onHold ?: 0 }} + {{ 'coreshop.inventory.stock.on_hand'|trans({'%on_hand%': stockable.onHand ?: 0}) }} / {{ 'coreshop.inventory.stock.on_hold'|trans({'%on_hold%': stockable.onHold ?: 0}) }}
{% else %}
- Stock Tracking is disabled + {{ 'coreshop.inventory.stock.not_tracked'|trans }}
{% endif %} \ No newline at end of file From 6d20172a65b66af106f4509703602712b73ea5df Mon Sep 17 00:00:00 2001 From: CoreShop Date: Mon, 26 Aug 2024 02:35:30 +0000 Subject: [PATCH 06/11] [CS] Refactor --- .../CurrencyBundle/CoreExtension/MoneyCurrency.php | 3 +-- .../Pimcore/Renderer/StockOnHandRenderer.php | 5 +++-- .../Exception/ReplyToSymfonyResponseConverter.php | 13 ++++++------- .../CoreShopStorageListExtension.php | 8 ++++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/CoreShop/Bundle/CurrencyBundle/CoreExtension/MoneyCurrency.php b/src/CoreShop/Bundle/CurrencyBundle/CoreExtension/MoneyCurrency.php index 3a5d9f0b45..eb7efa17b3 100644 --- a/src/CoreShop/Bundle/CurrencyBundle/CoreExtension/MoneyCurrency.php +++ b/src/CoreShop/Bundle/CurrencyBundle/CoreExtension/MoneyCurrency.php @@ -18,7 +18,6 @@ namespace CoreShop\Bundle\CurrencyBundle\CoreExtension; -use Carbon\Carbon; use CoreShop\Bundle\ResourceBundle\Pimcore\CacheMarshallerInterface; use CoreShop\Component\Currency\Model\CurrencyInterface; use CoreShop\Component\Currency\Model\Money; @@ -232,7 +231,7 @@ public function getDataForGrid(?Money $data, Concrete $object = null, array $par 'id' => $data->getCurrency()?->getId(), 'name' => $data->getCurrency()?->getName(), 'isoCode' => $data->getCurrency()?->getIsoCode(), - ] + ], ]; } diff --git a/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php b/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php index dd6961f1df..f505664355 100644 --- a/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php +++ b/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php @@ -26,8 +26,9 @@ class StockOnHandRenderer implements DynamicTextLabelInterface { - public function __construct(private Environment $twig) - { + public function __construct( + private Environment $twig, + ) { } public function renderLayoutText(string $data, ?Concrete $object, array $params): string diff --git a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php index 2f248b3055..906d316149 100644 --- a/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php +++ b/src/CoreShop/Bundle/PayumBundle/Exception/ReplyToSymfonyResponseConverter.php @@ -26,21 +26,20 @@ */ if (false) { //This is just for the IDE - class BaseCoreShopReplayToSymfonyResponseConverter { - public function convert(ReplyInterface $reply): Response { + class BaseCoreShopReplayToSymfonyResponseConverter + { + public function convert(ReplyInterface $reply): Response + { throw new \RuntimeException('Not implemented'); } } } - if (class_exists('Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter')) { \class_alias(\Payum\Bundle\PayumBundle\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter'); -} -elseif (class_exists('Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter')) { +} elseif (class_exists('Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter')) { \class_alias(\Payum\Core\Bridge\Symfony\ReplyToSymfonyResponseConverter::class, 'CoreShop\Bundle\PayumBundle\Exception\BaseCoreShopReplayToSymfonyResponseConverter'); -} -else { +} else { throw new \RuntimeException('Cannot find Payum ReplyToSymfonyResponseConverter class'); } diff --git a/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php b/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php index ed659f0b31..f94fbf58a0 100644 --- a/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php +++ b/src/CoreShop/Bundle/StorageListBundle/DependencyInjection/CoreShopStorageListExtension.php @@ -229,13 +229,13 @@ public function load(array $configs, ContainerBuilder $container): void [ 'event' => LogoutEvent::class, 'method' => 'onLogoutSuccess', - 'dispatcher' => 'security.event_dispatcher.coreshop_frontend' - ] + 'dispatcher' => 'security.event_dispatcher.coreshop_frontend', + ], ); $container->setDefinition( - 'coreshop.storage_list.logout_subscriber.'.$name, - $logoutSubscriber + 'coreshop.storage_list.logout_subscriber.' . $name, + $logoutSubscriber, ); } } From 5fa6d922d5797bda078a9b4f291ba35b9c14a8b7 Mon Sep 17 00:00:00 2001 From: Ben Walch Date: Tue, 27 Aug 2024 21:33:42 +0200 Subject: [PATCH 07/11] respect user language for grid filter labels (#2694) --- .../Bundle/PimcoreBundle/Controller/Admin/GridController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php b/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php index 8cdc4ea1df..c716409873 100644 --- a/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php +++ b/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php @@ -45,7 +45,7 @@ public function getGridFiltersAction( $services[] = [ 'id' => $id, - 'name' => $translator->trans($service->getName(), [], 'admin'), + 'name' => $translator->trans($service->getName(), [], 'admin', $this->getAdminUser()->getLanguage()), ]; } @@ -66,7 +66,7 @@ public function getGridActionsAction( $services[] = [ 'id' => $id, - 'name' => $translator->trans($service->getName(), [], 'admin'), + 'name' => $translator->trans($service->getName(), [], 'admin', $this->getAdminUser()->getLanguage()), ]; } From b2756d91e9037f74620d170ef8f3a0dfbc083835 Mon Sep 17 00:00:00 2001 From: Ben Walch Date: Wed, 28 Aug 2024 08:58:45 +0200 Subject: [PATCH 08/11] fix tests (#2694) --- .../Controller/Admin/GridController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php b/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php index c716409873..eb0834692d 100644 --- a/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php +++ b/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php @@ -37,6 +37,11 @@ public function getGridFiltersAction( TranslatorInterface $translator, ): Response { $services = []; + /** + * @var \Pimcore\Model\User $user + * @psalm-suppress InternalMethod + */ + $user = $this->getAdminUser(); /** @var GridFilterInterface $service */ foreach ($gridFilterServiceRegistry->all() as $id => $service) { if ($service->supports($listType) !== true) { @@ -45,7 +50,7 @@ public function getGridFiltersAction( $services[] = [ 'id' => $id, - 'name' => $translator->trans($service->getName(), [], 'admin', $this->getAdminUser()->getLanguage()), + 'name' => $translator->trans($service->getName(), [], 'admin', $user->getLanguage()), ]; } @@ -58,6 +63,11 @@ public function getGridActionsAction( TranslatorInterface $translator, ): Response { $services = []; + /** + * @var \Pimcore\Model\User $user + * @psalm-suppress InternalMethod + */ + $user = $this->getAdminUser(); /** @var GridActionInterface $service */ foreach ($gridActionServiceRegistry->all() as $id => $service) { if ($service->supports($listType) !== true) { @@ -66,7 +76,7 @@ public function getGridActionsAction( $services[] = [ 'id' => $id, - 'name' => $translator->trans($service->getName(), [], 'admin', $this->getAdminUser()->getLanguage()), + 'name' => $translator->trans($service->getName(), [], 'admin', $user->getLanguage()), ]; } From b038cd6a1119cb8dc4c88858e689859e4360cd45 Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Thu, 29 Aug 2024 07:32:13 +0200 Subject: [PATCH 09/11] [Behat] disable dev-tools in test browser --- .github/workflows/behat_ui.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/behat_ui.yml b/.github/workflows/behat_ui.yml index 7f74f6851a..615de46b86 100644 --- a/.github/workflows/behat_ui.yml +++ b/.github/workflows/behat_ui.yml @@ -33,6 +33,7 @@ jobs: PIMCORE_INSTALL_MYSQL_PORT: "3306" PANTHER_EXTERNAL_BASE_URI: "http://localhost:9080/index_test.php" PANTHER_CHROME_ARGUMENTS: "--disable-dev-shm-usage" + PANTHER_DEVTOOLS: "0" PIMCORE_KERNEL_CLASS: 'Kernel' strategy: From c4ab52889eb52a776cd5e9571c03a070225aa592 Mon Sep 17 00:00:00 2001 From: CoreShop Date: Mon, 2 Sep 2024 02:41:33 +0000 Subject: [PATCH 10/11] [CS] Refactor --- .../Bundle/PimcoreBundle/Controller/Admin/GridController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php b/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php index eb0834692d..7d6cbb5af3 100644 --- a/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php +++ b/src/CoreShop/Bundle/PimcoreBundle/Controller/Admin/GridController.php @@ -39,6 +39,7 @@ public function getGridFiltersAction( $services = []; /** * @var \Pimcore\Model\User $user + * * @psalm-suppress InternalMethod */ $user = $this->getAdminUser(); @@ -65,6 +66,7 @@ public function getGridActionsAction( $services = []; /** * @var \Pimcore\Model\User $user + * * @psalm-suppress InternalMethod */ $user = $this->getAdminUser(); From 9a0ed103f3a0f3d5b5bdfa94f4125c6cb432acfb Mon Sep 17 00:00:00 2001 From: Dominik Pfaffenbauer Date: Tue, 3 Sep 2024 09:29:50 +0200 Subject: [PATCH 11/11] [Docs] changes from AppBundle to App and easier Entity overwrites --- docs/02_Bundles/Menu_Bundle.md | 4 +- .../01_Extend_CoreShop_Resources.md | 92 +++++++++---------- .../02_Extend_CoreShop_Forms.md | 13 ++- .../03_Extend_CoreShop_DataObjects.md | 4 +- .../04_Extending_Rule_Actions.md | 9 +- .../05_Extending_Rule_Conditions.md | 9 +- .../02_Countries/02_Context.md | 7 +- .../03_Products/02_Price_Calculation.md | 5 +- .../04_Cart/04_Cart_Processor.md | 5 +- .../03_Development/06_Order/05_Purchasable.md | 5 +- .../06_Order/08_OrderList/01_Filter.md | 4 +- .../06_Order/08_OrderList/02_Action.md | 4 +- .../01_Index/01_Interpreter.md | 9 +- .../02_Filter/01_Custom_Filter.md | 17 ++-- .../09_Notification_Rules/03_Custom_Types.md | 5 +- .../10_Payment/01_Payment_Provider.md | 5 +- .../10_Payment/02_Omnipay_Bridge.md | 8 +- docs/03_Development/11_Stores/02_Context.md | 7 +- .../13_Ecommerce_Tracking/index.md | 3 +- .../15_Store_Front/01_Controllers.md | 4 +- .../17_State_Machine/02_Create_Callbacks.md | 10 +- .../17_State_Machine/04_Extend_Workflows.md | 4 +- 22 files changed, 103 insertions(+), 130 deletions(-) diff --git a/docs/02_Bundles/Menu_Bundle.md b/docs/02_Bundles/Menu_Bundle.md index da1952dbe1..7cf5be0c5b 100644 --- a/docs/02_Bundles/Menu_Bundle.md +++ b/docs/02_Bundles/Menu_Bundle.md @@ -29,7 +29,7 @@ Create a new Menu by creating a new Class, let's call it `MyMenuBuilder` ```php -namespace AppBundle\Menu; +namespace App\CoreShop\Menu; use CoreShop\Bundle\MenuBundle\Builder\MenuBuilderInterface; use Knp\Menu\FactoryInterface; @@ -54,7 +54,7 @@ You then need to register your class to the symfony container: ```yml app.my_menu: - class: AppBundle\Menu\MyMenuBuilder + class: App\CoreShop\Menu\MyMenuBuilder tags: - { name: coreshop.menu, type: my_menu, menu: my_menu } diff --git a/docs/03_Development/01_Extending_Guide/01_Extend_CoreShop_Resources.md b/docs/03_Development/01_Extending_Guide/01_Extend_CoreShop_Resources.md index a82b9df1b9..81ddeccb24 100644 --- a/docs/03_Development/01_Extending_Guide/01_Extend_CoreShop_Resources.md +++ b/docs/03_Development/01_Extending_Guide/01_Extend_CoreShop_Resources.md @@ -6,32 +6,23 @@ All models in Coreshop are placed in the ```Coreshop\Component\*ComponentName*\M ## How to Customize a Model -First things first: If you want to extend coreshop models your Bundle must extend the `AbstractResourceBundle`. Next you have set your supported drivers. Just add the following lines of code to your bundle class: +### Doctrine ORM -```php -public function getSupportedDrivers(); array -{ - return [ - CoreShopResourceBundle::DRIVER_DOCTRINE_ORM - ]; -} - ``` - After that have to tell the bundle where your models are. For that, add the override the following method in your bundle class and return the model namespace. Here is an example for the `AppBundle` - -```php - protected function getModelNamespace(): string -{ - return "AppBundle\Model"; -} -``` -Here a quick overview for you which dictories are important for you, when customizing CoreShop models. +Depending on your Doctrine ORM configuration, you need to place your Models in the right Folder. The Default configuration, places them in the `Entity` directory: -| Folder | Description | -|--------|-------------| -| `AcmeBundle/Model` or `AcmeBundle/Entity` | Where your models are living | -| `AcmeBundle/config/doctrine/model` | Put your doctrine `.yml` config files in here | -| `AcmeBundle/config/serializer` | The serializer configs for the models| +```yaml +doctrine: + orm: + mappings: + App: + type: attribute + dir: '%kernel.project_dir%/src/App/Entity' + is_bundle: false + prefix: App\Entity + alias: App +``` +### Example Model Let’s take the [```CoreShop\Component\Currency\Model\Currency```](https://github.com/coreshop/CoreShop/blob/master/src/CoreShop/Component/Currency/Model/Currency.php) as an example. This one is extended in Core. How can you check that? @@ -50,50 +41,35 @@ Assuming you want to add a field called **flag** ```php flag; } - /** - * @param bool $flag - */ - public function setFlag($flag) + public function setFlag(bool $flag): void { $this->flag = $flag; } } ``` -**2**. Next define your entity’s mapping. - -The file should be placed in ```AppBundle/Resources/config/doctrine/Currency.orm.yml``` - -```yaml -AppBundle\Entity\Currency: - type: mappedSuperclass - table: coreshop_currency - fields: - flag: - type: boolean - nullable: true -``` - -**3**. Finally you’ll need to override the model’s class in the ```app/config/config.yml```. +**2**. Finally you’ll need to override the model’s class in the ```config/config.yaml```. Under the core_shop_* where * is the name of the bundle of the model you are customizing, in our case it will be the CoreShopCurrencyBundle -> core_shop_currency. @@ -103,10 +79,10 @@ core_shop_currency: resources: currency: classes: - model: AppBundle\Entity\Currency + model: App\Entity\Currency ``` -**4**. Update the database. There are two ways to do it. +**3**. Update the database. There are two ways to do it. via direct database schema update: @@ -121,3 +97,17 @@ Which we strongly recommend over updating the schema. $ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate ``` + +**4**. We also need a serializer group for the new field. This is done in the ```config/jms_serializer/Currency.yaml``` file. + +```yaml +App\Entity\Currency: + exclusion_policy: ALL + xml_root_name: store + properties: + flag: + expose: true + type: bool + groups: [Detailed] + +``` \ No newline at end of file diff --git a/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md b/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md index f68cb3cbff..8605c125c5 100644 --- a/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md +++ b/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md @@ -1,7 +1,7 @@ # Customizing Forms The forms in CoreShop are placed in the ``CoreShop\Bundle\*BundleName*\Form\Type`` namespaces and the extensions -will be placed in `AppBundle\Form\Extension`. +will be placed in `App\CoreShop\Form\Extension`. ## Why would you customize a Form? @@ -43,7 +43,7 @@ As a result you will get the [```CoreShop\Bundle\StoreBundle\Form\Type\StoreType ```php get('coreshop.tracking.manager')->trackCheckoutComplete($order) To add a custom tracker you need to implement the interface `CoreShop\Component\Tracking\Tracker\TrackerInterface` ```yaml -app.tracking.tracker.my_tracker: - class: AppBundle\Tracker\CustomTracker +App\CoreShop\Tracker\CustomTracker: parent: coreshop.tracking.tracker.ecommerce_tracker tags: - { name: coreshop.tracking.tracker, type: app-custom-tracker } diff --git a/docs/03_Development/15_Store_Front/01_Controllers.md b/docs/03_Development/15_Store_Front/01_Controllers.md index cafe094d78..bc33984ff1 100644 --- a/docs/03_Development/15_Store_Front/01_Controllers.md +++ b/docs/03_Development/15_Store_Front/01_Controllers.md @@ -27,7 +27,7 @@ core_shop_frontend: ```php