diff --git a/src/CoreShop/Bundle/CoreBundle/CoreShopCoreBundle.php b/src/CoreShop/Bundle/CoreBundle/CoreShopCoreBundle.php index 657d1dd871..2125109620 100644 --- a/src/CoreShop/Bundle/CoreBundle/CoreShopCoreBundle.php +++ b/src/CoreShop/Bundle/CoreBundle/CoreShopCoreBundle.php @@ -23,8 +23,6 @@ use CoreShop\Bundle\CoreBundle\DependencyInjection\Compiler\RegisterIndexProductExtensionPass; use CoreShop\Bundle\CoreBundle\DependencyInjection\Compiler\RegisterPortletsPass; use CoreShop\Bundle\CoreBundle\DependencyInjection\Compiler\RegisterReportsPass; -use CoreShop\Bundle\ProductQuantityPriceRulesBundle\DependencyInjection\Compiler\ProductQuantityPriceRulesActionPass; -use CoreShop\Bundle\ProductQuantityPriceRulesBundle\DependencyInjection\Compiler\ProductQuantityPriceRulesConditionPass; use CoreShop\Bundle\CurrencyBundle\CoreShopCurrencyBundle; use CoreShop\Bundle\CustomerBundle\CoreShopCustomerBundle; use CoreShop\Bundle\IndexBundle\CoreShopIndexBundle; @@ -50,7 +48,6 @@ use Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle; use Pimcore\Bundle\CustomReportsBundle\PimcoreCustomReportsBundle; use Pimcore\HttpKernel\BundleCollection\BundleCollection; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; @@ -70,12 +67,6 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new RegisterIndexProductExtensionPass()); $container->addCompilerPass(new RegisterReportsPass()); $container->addCompilerPass(new RegisterPortletsPass()); - - $registerFormTypesFromTagsPassClass = self::getRegisterFormTypesFromTagsPassClass(); - if (null !== $registerFormTypesFromTagsPassClass) { - $container->addCompilerPass(new $registerFormTypesFromTagsPassClass(ProductQuantityPriceRulesConditionPass::PRODUCT_QUANTITY_PRICE_RULE_CONDITION_TAG)); - $container->addCompilerPass(new $registerFormTypesFromTagsPassClass(ProductQuantityPriceRulesActionPass::PRODUCT_QUANTITY_PRICE_RULE_ACTION_TAG)); - } } public static function registerDependentBundles(BundleCollection $collection): void @@ -187,20 +178,4 @@ private static function getStudioFormBundleClass(): ?string return $studioFormBundleClass; } - /** - * @return class-string|null - */ - private static function getRegisterFormTypesFromTagsPassClass(): ?string - { - $registerFormTypesFromTagsPassClass = sprintf( - 'CoreShop\\Bundle\\%s\\DependencyInjection\\Compiler\\RegisterFormTypesFromTagsPass', - 'StudioFormBundle', - ); - - if (!class_exists($registerFormTypesFromTagsPassClass) || !is_subclass_of($registerFormTypesFromTagsPassClass, CompilerPassInterface::class)) { - return null; - } - - return $registerFormTypesFromTagsPassClass; - } } diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/AbstractStateTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/AbstractStateTransitionConfigurationType.php new file mode 100644 index 0000000000..19e51a7730 --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/AbstractStateTransitionConfigurationType.php @@ -0,0 +1,47 @@ + $transition->getName(), + $this->workflow->getDefinition()->getTransitions(), + ); + $unique = array_values(array_unique($names)); + $choices = array_combine($unique, $unique); + + $builder->add('transition', ChoiceType::class, [ + 'label' => 'coreshop_select_transition', + 'choices' => $choices, + 'placeholder' => null, + ]); + } +} diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/AbstractWorkflowPlaceConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/AbstractWorkflowPlaceConfigurationType.php new file mode 100644 index 0000000000..2e25401fb1 --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/AbstractWorkflowPlaceConfigurationType.php @@ -0,0 +1,45 @@ +workflow->getDefinition()->getPlaces()); + $choices = array_combine($places, $places); + + $builder->add($this->getFieldName(), ChoiceType::class, [ + 'label' => 'coreshop_select_state', + 'choices' => $choices, + 'placeholder' => null, + ]); + } + + abstract protected function getFieldName(): string; +} diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/InvoiceStateConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/InvoiceStateConfigurationType.php index dc10ab9f31..a64b23565f 100644 --- a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/InvoiceStateConfigurationType.php +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/InvoiceStateConfigurationType.php @@ -17,19 +17,11 @@ namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; - -final class InvoiceStateConfigurationType extends AbstractType +final class InvoiceStateConfigurationType extends AbstractWorkflowPlaceConfigurationType { - public function buildForm(FormBuilderInterface $builder, array $options): void + protected function getFieldName(): string { - $builder - ->add('invoiceState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'invoiceState'; } public function getBlockPrefix(): string diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/InvoiceTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/InvoiceTransitionConfigurationType.php new file mode 100644 index 0000000000..9d4ad1d095 --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/InvoiceTransitionConfigurationType.php @@ -0,0 +1,26 @@ +add('orderInvoiceState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'orderInvoiceState'; } public function getBlockPrefix(): string diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderInvoiceTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderInvoiceTransitionConfigurationType.php new file mode 100644 index 0000000000..7b073e95c0 --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderInvoiceTransitionConfigurationType.php @@ -0,0 +1,26 @@ +add('orderPaymentState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'orderPaymentState'; } public function getBlockPrefix(): string diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderPaymentTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderPaymentTransitionConfigurationType.php new file mode 100644 index 0000000000..dca518ce7a --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderPaymentTransitionConfigurationType.php @@ -0,0 +1,26 @@ +add('saleState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'coreshop_notification_condition_order_sale_state'; } } diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderShippingStateConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderShippingStateConfigurationType.php index 4d5f04e9fa..5452aba7f4 100644 --- a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderShippingStateConfigurationType.php +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderShippingStateConfigurationType.php @@ -17,19 +17,11 @@ namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; - -final class OrderShippingStateConfigurationType extends AbstractType +final class OrderShippingStateConfigurationType extends AbstractWorkflowPlaceConfigurationType { - public function buildForm(FormBuilderInterface $builder, array $options): void + protected function getFieldName(): string { - $builder - ->add('orderShippingState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'orderShippingState'; } public function getBlockPrefix(): string diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderShippingTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderShippingTransitionConfigurationType.php new file mode 100644 index 0000000000..08040010be --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderShippingTransitionConfigurationType.php @@ -0,0 +1,26 @@ +add('orderState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'orderState'; } public function getBlockPrefix(): string diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/StateTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderTransitionConfigurationType.php similarity index 50% rename from src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/StateTransitionConfigurationType.php rename to src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderTransitionConfigurationType.php index 342e710416..1d09f82e00 100644 --- a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/StateTransitionConfigurationType.php +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/OrderTransitionConfigurationType.php @@ -17,23 +17,10 @@ namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; - -final class StateTransitionConfigurationType extends AbstractType +final class OrderTransitionConfigurationType extends AbstractStateTransitionConfigurationType { - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('transition', TextType::class, [ - 'label' => 'coreshop_select_transition', - ]) - ; - } - public function getBlockPrefix(): string { - return 'coreshop_notification_condition_state_transition'; + return 'coreshop_notification_condition_order_transition'; } } diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/PaymentStateConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/PaymentStateConfigurationType.php index 5a4afc8b22..cffcb04948 100644 --- a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/PaymentStateConfigurationType.php +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/PaymentStateConfigurationType.php @@ -17,19 +17,11 @@ namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; - -final class PaymentStateConfigurationType extends AbstractType +final class PaymentStateConfigurationType extends AbstractWorkflowPlaceConfigurationType { - public function buildForm(FormBuilderInterface $builder, array $options): void + protected function getFieldName(): string { - $builder - ->add('paymentState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'paymentState'; } public function getBlockPrefix(): string diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/PaymentTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/PaymentTransitionConfigurationType.php new file mode 100644 index 0000000000..e551202934 --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/PaymentTransitionConfigurationType.php @@ -0,0 +1,26 @@ +add('quoteState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]); + return 'coreshop_notification_condition_quote_state'; } } diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/QuoteTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/QuoteTransitionConfigurationType.php new file mode 100644 index 0000000000..bb92a74a84 --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/QuoteTransitionConfigurationType.php @@ -0,0 +1,26 @@ +add('shipmentState', TextType::class, [ - 'label' => 'coreshop_select_state', - ]) - ; + return 'shipmentState'; } public function getBlockPrefix(): string diff --git a/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/ShipmentTransitionConfigurationType.php b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/ShipmentTransitionConfigurationType.php new file mode 100644 index 0000000000..9e27b4f025 --- /dev/null +++ b/src/CoreShop/Bundle/CoreBundle/Form/Type/Notification/Condition/ShipmentTransitionConfigurationType.php @@ -0,0 +1,26 @@ + 'coreshop_condition_stores', 'allow_add' => true, 'allow_delete' => true, + 'block_prefix' => 'coreshop_store_choice', ]) ; } diff --git a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/notification.yml b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/notification.yml index b742dec98f..e1b0a34223 100644 --- a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/notification.yml +++ b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/notification.yml @@ -1,4 +1,84 @@ services: + # FormTypes für Notification Conditions/Actions + # autoconfigure: true sorgt dafür, dass FormTypeInterface-Implementierungen automatisch + # mit `form.type` getaggt werden. RegisterStudioFormTypesPass übernimmt sie dann in die + # BlockPrefixFormTypeRegistry, sodass /pimcore-studio-form/schema/{blockPrefix} sie kennt. + CoreShop\Bundle\CoreBundle\Form\Type\Notification\: + resource: '../../Form/Type/Notification/' + public: true + autoconfigure: true + + # Workflow-aware State/Transition FormTypes — explicit definitions override the glob + # to inject the matching `state_machine.*` service. Each FormType lists the workflow's + # places (State) or transitions (Transition) as ChoiceType options. + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderStateConfigurationType: + arguments: ['@state_machine.coreshop_order'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderInvoiceStateConfigurationType: + arguments: ['@state_machine.coreshop_order_invoice'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderPaymentStateConfigurationType: + arguments: ['@state_machine.coreshop_order_payment'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderShippingStateConfigurationType: + arguments: ['@state_machine.coreshop_order_shipment'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderSaleStateConfigurationType: + arguments: ['@state_machine.coreshop_order_sales_type'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\QuoteStateConfigurationType: + arguments: ['@state_machine.coreshop_quote'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\InvoiceStateConfigurationType: + arguments: ['@state_machine.coreshop_invoice'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\PaymentStateConfigurationType: + arguments: ['@state_machine.coreshop_payment'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\ShipmentStateConfigurationType: + arguments: ['@state_machine.coreshop_shipment'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderTransitionConfigurationType: + arguments: ['@state_machine.coreshop_order'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderInvoiceTransitionConfigurationType: + arguments: ['@state_machine.coreshop_order_invoice'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderPaymentTransitionConfigurationType: + arguments: ['@state_machine.coreshop_order_payment'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderShippingTransitionConfigurationType: + arguments: ['@state_machine.coreshop_order_shipment'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\QuoteTransitionConfigurationType: + arguments: ['@state_machine.coreshop_quote'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\InvoiceTransitionConfigurationType: + arguments: ['@state_machine.coreshop_invoice'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\PaymentTransitionConfigurationType: + arguments: ['@state_machine.coreshop_payment'] + tags: [{ name: form.type }] + + CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\ShipmentTransitionConfigurationType: + arguments: ['@state_machine.coreshop_shipment'] + tags: [{ name: form.type }] + # Notification Rule Conditions #### ORDER ##### Order Invoice State @@ -17,7 +97,7 @@ services: - 'CoreShop\Component\Order\Model\OrderInterface' - !php/const CoreShop\Component\Order\OrderInvoiceTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: orderInvoiceTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: orderInvoiceTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderInvoiceTransitionConfigurationType } ##### Order Payment State coreshop.notification_rule.condition.order.order_payment_state: @@ -35,7 +115,7 @@ services: - 'CoreShop\Component\Order\Model\OrderInterface' - !php/const CoreShop\Component\Order\OrderPaymentTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: orderPaymentTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: orderPaymentTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderPaymentTransitionConfigurationType } ##### Order Shipment State @@ -54,7 +134,7 @@ services: - 'CoreShop\Component\Order\Model\OrderInterface' - !php/const CoreShop\Component\Order\OrderShipmentTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: orderShippingTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: orderShippingTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderShippingTransitionConfigurationType } ##### Order State coreshop.notification_rule.condition.order.order_state: @@ -82,7 +162,7 @@ services: - 'CoreShop\Component\Order\Model\OrderInterface' - !php/const CoreShop\Component\Order\OrderTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: orderTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: orderTransition, notification-type: order, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\OrderTransitionConfigurationType } ##### Quote coreshop.notification_rule.condition.quote.quote_state: @@ -100,7 +180,7 @@ services: - 'CoreShop\Component\Order\Model\OrderInterface' - !php/const CoreShop\Component\Order\QuoteTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: quoteTransition, notification-type: quote, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: quoteTransition, notification-type: quote, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\QuoteTransitionConfigurationType } ##### MISC CoreShop\Component\Core\Notification\Rule\Condition\Order\CarriersChecker: @@ -136,7 +216,7 @@ services: - 'CoreShop\Component\Payment\Model\PaymentInterface' - !php/const CoreShop\Component\Payment\PaymentTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: paymentTransition, notification-type: payment, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: paymentTransition, notification-type: payment, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\PaymentTransitionConfigurationType } #### INVOICE coreshop.notification_rule.condition.invoice.state: @@ -154,7 +234,7 @@ services: - 'CoreShop\Component\Order\Model\OrderInvoiceInterface' - !php/const CoreShop\Component\Order\InvoiceTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: invoiceTransition, notification-type: invoice, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: invoiceTransition, notification-type: invoice, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\InvoiceTransitionConfigurationType } #### SHIPMENT coreshop.notification_rule.condition.shipment.state: @@ -172,7 +252,7 @@ services: - 'CoreShop\Component\Order\Model\OrderShipmentInterface' - !php/const CoreShop\Component\Order\ShipmentTransitions::IDENTIFIER tags: - - { name: coreshop.notification_rule.condition, type: shipmentTransition, notification-type: shipment, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\StateTransitionConfigurationType } + - { name: coreshop.notification_rule.condition, type: shipmentTransition, notification-type: shipment, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition\ShipmentTransitionConfigurationType } #### USER coreshop.notification_rule.condition.user.user_type: diff --git a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/rules.yml b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/rules.yml index 4b453715af..66ac33cfa6 100644 --- a/src/CoreShop/Bundle/CoreBundle/Resources/config/services/rules.yml +++ b/src/CoreShop/Bundle/CoreBundle/Resources/config/services/rules.yml @@ -2,6 +2,13 @@ services: _defaults: public: true + # FormTypes für die Rule-Engine-Conditions/Actions in CoreBundle. + # autoconfigure: true taggt sie automatisch mit `form.type`, sodass + # RegisterStudioFormTypesPass sie in die BlockPrefixFormTypeRegistry übernimmt. + CoreShop\Bundle\CoreBundle\Form\Type\Rule\: + resource: '../../Form/Type/Rule/' + autoconfigure: true + coreshop.rule.condition.customers: class: CoreShop\Component\Core\Product\Rule\Condition\CustomersConditionChecker tags: diff --git a/src/CoreShop/Bundle/IndexBundle/Worker/OpenSearchWorker.php b/src/CoreShop/Bundle/IndexBundle/Worker/OpenSearchWorker.php index 00324e3b26..f99c25d0ec 100644 --- a/src/CoreShop/Bundle/IndexBundle/Worker/OpenSearchWorker.php +++ b/src/CoreShop/Bundle/IndexBundle/Worker/OpenSearchWorker.php @@ -161,12 +161,17 @@ public function renameIndexStructures(IndexInterface $index, string $oldName, st */ public function deleteFromIndexById(IndexInterface $index, int $id): void { - $this->getClient($index) - ->delete([ - 'index' => $this->getIndexName($index->getName()), - 'id' => (string) $id, - ]) - ; + $client = $this->getClient($index); + $indexName = $this->getIndexName($index->getName()); + + if (!$client->exists(['index' => $indexName, 'id' => (string) $id])) { + return; + } + + $client->delete([ + 'index' => $indexName, + 'id' => (string) $id, + ]); } /** @@ -174,12 +179,13 @@ public function deleteFromIndexById(IndexInterface $index, int $id): void */ public function deleteFromIndex(IndexInterface $index, IndexableInterface $object): void { - $this->getClient($index) - ->delete([ - 'index' => $this->getIndexName($index->getName()), - 'id' => (string) $object->getId(), - ]) - ; + $id = $object->getId(); + + if (!is_int($id)) { + return; + } + + $this->deleteFromIndexById($index, $id); } /** diff --git a/src/CoreShop/Bundle/NotificationBundle/Resources/config/services/form.yml b/src/CoreShop/Bundle/NotificationBundle/Resources/config/services/form.yml index 5927b0b48e..a54f42ccfe 100644 --- a/src/CoreShop/Bundle/NotificationBundle/Resources/config/services/form.yml +++ b/src/CoreShop/Bundle/NotificationBundle/Resources/config/services/form.yml @@ -9,6 +9,13 @@ services: _defaults: public: true + # FormTypes für Notification Rule Conditions/Actions (z. B. MailActionConfigurationType). + # autoconfigure: true taggt sie automatisch mit `form.type`, sodass + # RegisterStudioFormTypesPass sie in die BlockPrefixFormTypeRegistry übernimmt. + CoreShop\Bundle\NotificationBundle\Form\Type\Rule\: + resource: '../../../Form/Type/Rule/' + autoconfigure: true + CoreShop\Bundle\NotificationBundle\Form\Type\NotificationRuleType: arguments: - '%coreshop.model.notification_rule.class%' diff --git a/src/CoreShop/Bundle/OrderBundle/CoreShopOrderBundle.php b/src/CoreShop/Bundle/OrderBundle/CoreShopOrderBundle.php index e688d37bc0..7afd7838d5 100644 --- a/src/CoreShop/Bundle/OrderBundle/CoreShopOrderBundle.php +++ b/src/CoreShop/Bundle/OrderBundle/CoreShopOrderBundle.php @@ -24,7 +24,6 @@ use CoreShop\Bundle\OrderBundle\DependencyInjection\Compiler\CartItemPriceRuleConditionPass; use CoreShop\Bundle\OrderBundle\DependencyInjection\Compiler\CartPriceRuleActionPass; use CoreShop\Bundle\OrderBundle\DependencyInjection\Compiler\CartPriceRuleConditionPass; -use CoreShop\Bundle\StudioFormBundle\DependencyInjection\Compiler\RegisterFormTypesFromTagsPass; use CoreShop\Bundle\OrderBundle\DependencyInjection\Compiler\PurchasableCustomAttributesCalculatorsPass; use CoreShop\Bundle\OrderBundle\DependencyInjection\Compiler\PurchasableDiscountCalculatorsPass; use CoreShop\Bundle\OrderBundle\DependencyInjection\Compiler\PurchasableDiscountPriceCalculatorsPass; @@ -68,11 +67,6 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new PurchasableRetailPriceCalculatorsPass()); $container->addCompilerPass(new PurchasableWholesalePriceCalculatorsPass()); $container->addCompilerPass(new PurchasableCustomAttributesCalculatorsPass()); - - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(CartPriceRuleConditionPass::CART_PRICE_RULE_CONDITION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(CartPriceRuleActionPass::CART_PRICE_RULE_ACTION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(CartItemPriceRuleConditionPass::CART_ITEM_PRICE_RULE_CONDITION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(CartItemPriceRuleActionPass::CART_ITEM_PRICE_RULE_ACTION_TAG)); } public static function registerDependentBundles(BundleCollection $collection): void diff --git a/src/CoreShop/Bundle/PaymentBundle/CoreShopPaymentBundle.php b/src/CoreShop/Bundle/PaymentBundle/CoreShopPaymentBundle.php index e1de37a573..e62eee26a4 100644 --- a/src/CoreShop/Bundle/PaymentBundle/CoreShopPaymentBundle.php +++ b/src/CoreShop/Bundle/PaymentBundle/CoreShopPaymentBundle.php @@ -20,7 +20,6 @@ use CoreShop\Bundle\PaymentBundle\DependencyInjection\Compiler\PaymentCalculatorsPass; use CoreShop\Bundle\PaymentBundle\DependencyInjection\Compiler\PaymentProviderRuleActionPass; use CoreShop\Bundle\PaymentBundle\DependencyInjection\Compiler\PaymentProviderRuleConditionPass; -use CoreShop\Bundle\StudioFormBundle\DependencyInjection\Compiler\RegisterFormTypesFromTagsPass; use CoreShop\Bundle\ResourceBundle\AbstractResourceBundle; use CoreShop\Bundle\ResourceBundle\CoreShopResourceBundle; use CoreShop\Bundle\RuleBundle\CoreShopRuleBundle; @@ -52,9 +51,6 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new PaymentProviderRuleConditionPass()); $container->addCompilerPass(new PaymentProviderRuleActionPass()); $container->addCompilerPass(new PaymentCalculatorsPass()); - - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(PaymentProviderRuleConditionPass::PAYMENT_PROVIDER_RULE_CONDITION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(PaymentProviderRuleActionPass::PAYMENT_PROVIDER_RULE_ACTION_TAG)); } protected function getModelNamespace(): string diff --git a/src/CoreShop/Bundle/ProductBundle/CoreShopProductBundle.php b/src/CoreShop/Bundle/ProductBundle/CoreShopProductBundle.php index 7310995d15..2dac765278 100644 --- a/src/CoreShop/Bundle/ProductBundle/CoreShopProductBundle.php +++ b/src/CoreShop/Bundle/ProductBundle/CoreShopProductBundle.php @@ -23,7 +23,6 @@ use CoreShop\Bundle\ProductBundle\DependencyInjection\Compiler\ProductDiscountPriceCalculatorsPass; use CoreShop\Bundle\ProductBundle\DependencyInjection\Compiler\ProductPriceRuleActionPass; use CoreShop\Bundle\ProductBundle\DependencyInjection\Compiler\ProductPriceRuleConditionPass; -use CoreShop\Bundle\StudioFormBundle\DependencyInjection\Compiler\RegisterFormTypesFromTagsPass; use CoreShop\Bundle\ProductBundle\DependencyInjection\Compiler\ProductRetailPriceCalculatorsPass; use CoreShop\Bundle\ProductBundle\DependencyInjection\Compiler\ProductSpecificPriceRuleActionPass; use CoreShop\Bundle\ProductBundle\DependencyInjection\Compiler\ProductSpecificPriceRuleConditionPass; @@ -57,11 +56,6 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new ProductDiscountPriceCalculatorsPass()); $container->addCompilerPass(new ProductDiscountCalculatorsPass()); $container->addCompilerPass(new ProductCustomAttributesCalculatorsPass()); - - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(ProductPriceRuleConditionPass::PRODUCT_PRICE_RULE_CONDITION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(ProductPriceRuleActionPass::PRODUCT_PRICE_RULE_ACTION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(ProductSpecificPriceRuleConditionPass::PRODUCT_SPECIFIC_PRICE_RULE_CONDITION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(ProductSpecificPriceRuleActionPass::PRODUCT_SPECIFIC_PRICE_RULE_ACTION_TAG)); } public static function registerDependentBundles(BundleCollection $collection): void diff --git a/src/CoreShop/Bundle/ProductQuantityPriceRulesBundle/Resources/config/services/rules.yml b/src/CoreShop/Bundle/ProductQuantityPriceRulesBundle/Resources/config/services/rules.yml index ae7bd22b13..a380e22e2e 100644 --- a/src/CoreShop/Bundle/ProductQuantityPriceRulesBundle/Resources/config/services/rules.yml +++ b/src/CoreShop/Bundle/ProductQuantityPriceRulesBundle/Resources/config/services/rules.yml @@ -2,6 +2,13 @@ services: _defaults: public: true + # FormTypes für QuantityPriceRule Conditions (NestedConfigurationType etc.). + # autoconfigure: true taggt sie automatisch mit `form.type`, sodass + # RegisterStudioFormTypesPass sie in die BlockPrefixFormTypeRegistry übernimmt. + CoreShop\Bundle\ProductQuantityPriceRulesBundle\Form\Type\Rule\: + resource: '../../Form/Type/Rule/' + autoconfigure: true + coreshop.product_quantity_price_rules.conditions.nested: class: CoreShop\Component\Rule\Condition\NestedConditionChecker arguments: diff --git a/src/CoreShop/Bundle/RuleBundle/Resources/config/services/form.yml b/src/CoreShop/Bundle/RuleBundle/Resources/config/services/form.yml index a3a49254f4..fc456262e9 100644 --- a/src/CoreShop/Bundle/RuleBundle/Resources/config/services/form.yml +++ b/src/CoreShop/Bundle/RuleBundle/Resources/config/services/form.yml @@ -1,8 +1,12 @@ services: - CoreShop\Bundle\RuleBundle\Form\Type\TimestampDateType: - tags: - - { name: form.type } + # FormTypes für Rule Conditions/Actions in RuleBundle (EmptyConfigurationFormType etc.). + # autoconfigure: true taggt sie automatisch mit `form.type`, sodass + # RegisterStudioFormTypesPass sie in die BlockPrefixFormTypeRegistry übernimmt. + CoreShop\Bundle\RuleBundle\Form\Type\Rule\: + resource: '../../Form/Type/Rule/' + public: true + autoconfigure: true - CoreShop\Bundle\RuleBundle\Form\Type\Rule\Condition\TimespanConfigurationType: + CoreShop\Bundle\RuleBundle\Form\Type\TimestampDateType: tags: - { name: form.type } diff --git a/src/CoreShop/Bundle/ShippingBundle/CoreShopShippingBundle.php b/src/CoreShop/Bundle/ShippingBundle/CoreShopShippingBundle.php index b7d25b4cdd..64a8fdcdb1 100644 --- a/src/CoreShop/Bundle/ShippingBundle/CoreShopShippingBundle.php +++ b/src/CoreShop/Bundle/ShippingBundle/CoreShopShippingBundle.php @@ -27,7 +27,6 @@ use CoreShop\Bundle\ShippingBundle\DependencyInjection\Compiler\ShippingPriceCalculatorsPass; use CoreShop\Bundle\ShippingBundle\DependencyInjection\Compiler\ShippingRuleActionPass; use CoreShop\Bundle\ShippingBundle\DependencyInjection\Compiler\ShippingRuleConditionPass; -use CoreShop\Bundle\StudioFormBundle\DependencyInjection\Compiler\RegisterFormTypesFromTagsPass; use CoreShop\Bundle\ShippingBundle\DependencyInjection\Compiler\ShippingTaxCalculationStrategyPass; use Pimcore\HttpKernel\BundleCollection\BundleCollection; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -50,9 +49,6 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new ShippingPriceCalculatorsPass()); $container->addCompilerPass(new CompositeShippableValidatorPass()); $container->addCompilerPass(new ShippingTaxCalculationStrategyPass()); - - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(ShippingRuleConditionPass::SHIPPING_RULE_CONDITION_TAG)); - $container->addCompilerPass(new RegisterFormTypesFromTagsPass(ShippingRuleActionPass::SHIPPING_RULE_ACTION_TAG)); } public static function registerDependentBundles(BundleCollection $collection): void diff --git a/src/CoreShop/Bundle/StudioFormBundle/DependencyInjection/Compiler/RegisterFormTypesFromTagsPass.php b/src/CoreShop/Bundle/StudioFormBundle/DependencyInjection/Compiler/RegisterFormTypesFromTagsPass.php deleted file mode 100644 index 571974d735..0000000000 --- a/src/CoreShop/Bundle/StudioFormBundle/DependencyInjection/Compiler/RegisterFormTypesFromTagsPass.php +++ /dev/null @@ -1,56 +0,0 @@ -addCompilerPass(new RegisterFormTypesFromTagsPass('coreshop.cart_price_rule.condition')); - * $container->addCompilerPass(new RegisterFormTypesFromTagsPass('coreshop.cart_price_rule.action')); - */ -final class RegisterFormTypesFromTagsPass implements CompilerPassInterface -{ - public function __construct( - private readonly string $tag, - private readonly string $attributeName = 'form-type', - ) { - } - - public function process(ContainerBuilder $container): void - { - if (!$container->hasDefinition(BlockPrefixFormTypeRegistry::class)) { - return; - } - - $registry = $container->getDefinition(BlockPrefixFormTypeRegistry::class); - - foreach ($container->findTaggedServiceIds($this->tag) as $id => $tags) { - foreach ($tags as $attributes) { - if (isset($attributes[$this->attributeName])) { - $registry->addMethodCall('addFormTypeClass', [$attributes[$this->attributeName]]); - } - } - } - } -} diff --git a/src/CoreShop/Bundle/StudioFormBundle/Form/Schema/BlockPrefixFormTypeRegistry.php b/src/CoreShop/Bundle/StudioFormBundle/Form/Schema/BlockPrefixFormTypeRegistry.php index 3bb641e720..3a4384ff6e 100644 --- a/src/CoreShop/Bundle/StudioFormBundle/Form/Schema/BlockPrefixFormTypeRegistry.php +++ b/src/CoreShop/Bundle/StudioFormBundle/Form/Schema/BlockPrefixFormTypeRegistry.php @@ -24,9 +24,6 @@ final class BlockPrefixFormTypeRegistry /** @var array|null */ private ?array $blockPrefixMap = null; - /** @var string[] */ - private array $additionalFormTypeClasses = []; - /** * @param string[] $formTypeClasses */ @@ -36,15 +33,6 @@ public function __construct( ) { } - /** - * Register an additional form type class (used by compiler passes for rule element form types). - */ - public function addFormTypeClass(string $formTypeClass): void - { - $this->additionalFormTypeClasses[] = $formTypeClass; - $this->blockPrefixMap = null; - } - public function resolve(string $blockPrefix): ?string { return $this->getMap()[$blockPrefix] ?? null; @@ -62,9 +50,8 @@ private function getMap(): array { if ($this->blockPrefixMap === null) { $this->blockPrefixMap = []; - $allClasses = array_unique(array_merge($this->formTypeClasses, $this->additionalFormTypeClasses)); - foreach ($allClasses as $class) { + foreach (array_unique($this->formTypeClasses) as $class) { $resolvedType = $this->formRegistry->getType($class); $this->blockPrefixMap[$resolvedType->getBlockPrefix()] = $class; }