Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/CoreShop/Bundle/CoreBundle/CoreShopCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -187,20 +178,4 @@ private static function getStudioFormBundleClass(): ?string
return $studioFormBundleClass;
}

/**
* @return class-string<CompilerPassInterface>|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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

/*
* CoreShop
*
* This source file is available under the terms of the
* CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.com)
* @license CoreShop Commercial License (CCL)
*
*/

namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Workflow\WorkflowInterface;

abstract class AbstractStateTransitionConfigurationType extends AbstractType
{
public function __construct(
private readonly WorkflowInterface $workflow,
) {
}

public function buildForm(FormBuilderInterface $builder, array $options): void
{
$names = array_map(
static fn ($transition) => $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,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

/*
* CoreShop
*
* This source file is available under the terms of the
* CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.com)
* @license CoreShop Commercial License (CCL)
*
*/

namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Workflow\WorkflowInterface;

abstract class AbstractWorkflowPlaceConfigurationType extends AbstractType
{
public function __construct(
private readonly WorkflowInterface $workflow,
) {
}

public function buildForm(FormBuilderInterface $builder, array $options): void
{
$places = array_keys($this->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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/*
* CoreShop
*
* This source file is available under the terms of the
* CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.com)
* @license CoreShop Commercial License (CCL)
*
*/

namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

final class InvoiceTransitionConfigurationType extends AbstractStateTransitionConfigurationType
{
public function getBlockPrefix(): string
{
return 'coreshop_notification_condition_invoice_transition';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 OrderInvoiceStateConfigurationType extends AbstractType
final class OrderInvoiceStateConfigurationType extends AbstractWorkflowPlaceConfigurationType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
protected function getFieldName(): string
{
$builder
->add('orderInvoiceState', TextType::class, [
'label' => 'coreshop_select_state',
])
;
return 'orderInvoiceState';
}

public function getBlockPrefix(): string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/*
* CoreShop
*
* This source file is available under the terms of the
* CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.com)
* @license CoreShop Commercial License (CCL)
*
*/

namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

final class OrderInvoiceTransitionConfigurationType extends AbstractStateTransitionConfigurationType
{
public function getBlockPrefix(): string
{
return 'coreshop_notification_condition_order_invoice_transition';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 OrderPaymentStateConfigurationType extends AbstractType
final class OrderPaymentStateConfigurationType extends AbstractWorkflowPlaceConfigurationType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
protected function getFieldName(): string
{
$builder
->add('orderPaymentState', TextType::class, [
'label' => 'coreshop_select_state',
])
;
return 'orderPaymentState';
}

public function getBlockPrefix(): string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/*
* CoreShop
*
* This source file is available under the terms of the
* CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.com)
* @license CoreShop Commercial License (CCL)
*
*/

namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

final class OrderPaymentTransitionConfigurationType extends AbstractStateTransitionConfigurationType
{
public function getBlockPrefix(): string
{
return 'coreshop_notification_condition_order_payment_transition';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@

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 OrderSaleStateConfigurationType extends AbstractType
final class OrderSaleStateConfigurationType extends AbstractWorkflowPlaceConfigurationType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
protected function getFieldName(): string
{
return 'saleState';
}

public function getBlockPrefix(): string
{
$builder
->add('saleState', TextType::class, [
'label' => 'coreshop_select_state',
])
;
return 'coreshop_notification_condition_order_sale_state';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

/*
* CoreShop
*
* This source file is available under the terms of the
* CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.com)
* @license CoreShop Commercial License (CCL)
*
*/

namespace CoreShop\Bundle\CoreBundle\Form\Type\Notification\Condition;

final class OrderShippingTransitionConfigurationType extends AbstractStateTransitionConfigurationType
{
public function getBlockPrefix(): string
{
return 'coreshop_notification_condition_order_shipping_transition';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 OrderStateConfigurationType extends AbstractType
final class OrderStateConfigurationType extends AbstractWorkflowPlaceConfigurationType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
protected function getFieldName(): string
{
$builder
->add('orderState', TextType::class, [
'label' => 'coreshop_select_state',
])
;
return 'orderState';
}

public function getBlockPrefix(): string
Expand Down
Loading
Loading