-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a support for Symfony Workflow while a refunding process
- Loading branch information
1 parent
97bc58c
commit 90ffd3b
Showing
7 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ jobs: | |
|
||
runs-on: ubuntu-latest | ||
|
||
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}" | ||
name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}, State Machine ${{ matrix.state_machine }}" | ||
|
||
strategy: | ||
fail-fast: false | ||
|
@@ -41,6 +41,7 @@ jobs: | |
env: | ||
APP_ENV: test | ||
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}" | ||
STATE_MACHINE_DEFAULT_ADAPTER: ${{ matrix.state_machine }} | ||
|
||
steps: | ||
- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Refunding/Workflow/Listener/DispatchRefundListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CommerceWeavers\SyliusTpayPlugin\Refunding\Workflow\Listener; | ||
|
||
use CommerceWeavers\SyliusTpayPlugin\Refunding\Dispatcher\RefundDispatcherInterface; | ||
use Sylius\Component\Core\Model\PaymentInterface; | ||
use Symfony\Component\Workflow\Event\TransitionEvent; | ||
|
||
final class DispatchRefundListener | ||
{ | ||
public function __construct( | ||
private RefundDispatcherInterface $refundDispatcher, | ||
) { | ||
} | ||
|
||
public function __invoke(TransitionEvent $event): void | ||
{ | ||
$payment = $event->getSubject(); | ||
|
||
if (!$payment instanceof PaymentInterface) { | ||
throw new \UnexpectedValueException( | ||
sprintf('Expected instance of "%s", got "%s"', PaymentInterface::class, get_class($payment)), | ||
); | ||
} | ||
|
||
$this->refundDispatcher->dispatch($payment); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/Application/config/packages/sylius_state_machine_abstraction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use Sylius\Bundle\CoreBundle\SyliusCoreBundle; | ||
|
||
if (SyliusCoreBundle::VERSION_ID < 11300) { | ||
return; | ||
} | ||
|
||
return function(ContainerConfigurator $container): void { | ||
$container->extension('sylius_state_machine_abstraction', [ | ||
'default_adapter' => '%env(STATE_MACHINE_DEFAULT_ADAPTER)%', | ||
]); | ||
}; |