Fix service definition and use state machine absctraction

This commit is contained in:
Francis Hilaire 2024-02-03 17:19:49 +01:00 committed by Grzegorz Sadowski
parent 166e1a97da
commit b9b3cd2b2d
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
2 changed files with 15 additions and 2 deletions

View file

@ -14,6 +14,7 @@ declare(strict_types=1);
namespace Sylius\Bundle\PaymentBundle\Processor;
use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
use Sylius\Abstraction\StateMachine\StateMachineInterface;
use Sylius\Component\Payment\Model\PaymentRequestInterface;
use Sylius\Component\Payment\PaymentTransitions;
use Webmozart\Assert\Assert;
@ -21,8 +22,19 @@ use Webmozart\Assert\Assert;
final class AfterOfflineCaptureProcessor implements AfterOfflineCaptureProcessorInterface
{
public function __construct(
private StateMachineFactoryInterface $stateMachineFactory,
private StateMachineFactoryInterface|StateMachineInterface $stateMachineFactory,
) {
if ($this->stateMachineFactory instanceof StateMachineFactoryInterface) {
trigger_deprecation(
'sylius/payment-bundle',
'1.13',
sprintf(
'Passing an instance of "%s" as the first argument is deprecated. It will accept only instances of "%s" in Sylius 2.0.',
StateMachineFactoryInterface::class,
StateMachineInterface::class,
),
);
}
}
public function process(PaymentRequestInterface $paymentRequest): void

View file

@ -40,8 +40,9 @@
</service>
<service id="Sylius\Bundle\PaymentBundle\Processor\OfflineCaptureProcessorInterface" class="Sylius\Bundle\PaymentBundle\Processor\OfflineCaptureProcessor" />
<service id="Sylius\Bundle\PaymentBundle\Processor\AfterOfflineCaptureProcessorInterface" class="Sylius\Bundle\PaymentBundle\Processor\AfterOfflineCaptureProcessor">
<argument tag="service" id="sm.factory" />
<argument type="service" id="sylius_abstraction.state_machine" />
</service>
</services>