minor #15989 [Maintenance] Revert deprecating and aliasing PaymentFixture (NoResponseMate)

This PR was merged into the 1.13 branch.

Discussion
----------

| Q               | A                                                            |
|-----------------|--------------------------------------------------------------|
| Branch?         | 1.13 |
| Bug fix?        | kinda                                                       |
| New feature?    | no                                                       |
| BC breaks?      | no                                                       |
| Deprecations?   | no |
| Related tickets | -                      |
| License         | MIT                                                          |

The original service has been added in 1.13, no point in aliasing/deprecating it, we can just move it.

Commits
-------
  [Maintenance] Revert deprecating and aliasing PaymentFixture
This commit is contained in:
Jacob Tobiasz 2024-03-13 19:03:08 +01:00 committed by GitHub
commit c0a3a05b77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 9 additions and 47 deletions

View file

@ -525,9 +525,6 @@ To ease the update process, we have grouped the changes into the following categ
same reason. Both changes affect
`sylius_admin_order` and `sylius_admin_customer_order` grids configuration.
1. The `Sylius\Bundle\CoreBundle\Fixture\Factory\PaymentFixture` has been deprecated.
Use `Sylius\Bundle\CoreBundle\Fixture\PaymentFixture` instead.
1. The `Sylius\Bundle\CoreBundle\Provider\SessionProvider` has been deprecated and will be removed in Sylius 2.0.
1. The `Sylius\Component\Addressing\Repository\ZoneRepositoryInterface` and

View file

@ -16,9 +16,7 @@ namespace Sylius\Bundle\CoreBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Faker\Factory;
use Faker\Generator;
use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
use Sylius\Abstraction\StateMachine\StateMachineInterface;
use Sylius\Abstraction\StateMachine\WinzouStateMachineAdapter;
use Sylius\Bundle\FixturesBundle\Fixture\AbstractFixture;
use Sylius\Component\Core\Model\PaymentInterface;
use Sylius\Component\Core\Repository\PaymentRepositoryInterface;
@ -26,16 +24,6 @@ use Sylius\Component\Payment\PaymentTransitions;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\OptionsResolver\OptionsResolver;
class_alias(PaymentFixture::class, '\Sylius\Bundle\CoreBundle\Fixture\Factory\PaymentFixture');
trigger_deprecation(
'sylius/core-bundle',
'1.13',
'The "%s" class is deprecated and will be removed in Sylius 2.0. Use "%s" instead.',
'\Sylius\Bundle\CoreBundle\Fixture\Factory\PaymentFixture',
PaymentFixture::class,
);
class PaymentFixture extends AbstractFixture
{
private Generator $faker;
@ -47,25 +35,13 @@ class PaymentFixture extends AbstractFixture
*/
public function __construct(
private PaymentRepositoryInterface $paymentRepository,
private StateMachineFactoryInterface|StateMachineInterface $stateMachineFactory,
private StateMachineInterface $stateMachine,
private ObjectManager $paymentManager,
) {
$this->faker = Factory::create();
$this->optionsResolver = new OptionsResolver();
$this->configureOptions($this->optionsResolver);
if ($this->stateMachineFactory instanceof StateMachineFactoryInterface) {
trigger_deprecation(
'sylius/core-bundle',
'1.13',
sprintf(
'Passing an instance of "%s" as the second argument is deprecated. It will accept only instances of "%s" in Sylius 2.0.',
StateMachineFactoryInterface::class,
StateMachineInterface::class,
),
);
}
}
public function getName(): string
@ -102,7 +78,7 @@ class PaymentFixture extends AbstractFixture
private function completePayment(PaymentInterface $payment): void
{
$this->getStateMachine()->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_COMPLETE);
$this->stateMachine->apply($payment, PaymentTransitions::GRAPH, PaymentTransitions::TRANSITION_COMPLETE);
$this->paymentManager->persist($payment);
}
@ -114,13 +90,4 @@ class PaymentFixture extends AbstractFixture
->setAllowedTypes('percentage_completed', 'int')
;
}
private function getStateMachine(): StateMachineInterface
{
if ($this->stateMachineFactory instanceof StateMachineFactoryInterface) {
return new WinzouStateMachineAdapter($this->stateMachineFactory);
}
return $this->stateMachineFactory;
}
}

View file

@ -211,5 +211,12 @@
<argument type="service" id="sylius.fixture.example_factory.address" />
<tag name="sylius_fixtures.fixture" />
</service>
<service id="sylius.fixture.payment" class="Sylius\Bundle\CoreBundle\Fixture\PaymentFixture">
<argument type="service" id="sylius.repository.payment" />
<argument type="service" id="sylius_abstraction.state_machine" />
<argument type="service" id="sylius.manager.payment" />
<tag name="sylius_fixtures.fixture" />
</service>
</services>
</container>

View file

@ -182,14 +182,5 @@
<argument type="service" id="sylius.checker.order_shipping_method_selection_requirement" />
<argument type="service" id="sylius.checker.order_payment_method_selection_requirement" />
</service>
<service id="Sylius\Bundle\CoreBundle\Fixture\PaymentFixture">
<argument type="service" id="sylius.repository.payment" />
<argument type="service" id="sylius_abstraction.state_machine" />
<argument type="service" id="sylius.manager.payment" />
<tag name="sylius_fixtures.fixture" />
</service>
<service id="Sylius\Bundle\CoreBundle\Fixture\Factory\PaymentFixture" alias="Sylius\Bundle\CoreBundle\Fixture\PaymentFixture" />
</services>
</container>