forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PayumBundle] Fix application crash while capturing payments
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...us/Bundle/PayumBundle/DependencyInjection/Compiler/InjectContainerIntoControllersPass.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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\PayumBundle\DependencyInjection\Compiler; | ||
|
||
use Payum\Bundle\PayumBundle\Controller; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* @see https://github.com/Payum/PayumBundle/issues/507 | ||
* | ||
* @internal | ||
*/ | ||
final class InjectContainerIntoControllersPass implements CompilerPassInterface | ||
{ | ||
private const SERVICES = [ | ||
Controller\AuthorizeController::class, | ||
Controller\CancelController::class, | ||
Controller\CaptureController::class, | ||
Controller\NotifyController::class, | ||
Controller\PayoutController::class, | ||
Controller\RefundController::class, | ||
Controller\SyncController::class, | ||
]; | ||
|
||
public function process(ContainerBuilder $container): void | ||
{ | ||
foreach (self::SERVICES as $service) { | ||
try { | ||
$definition = $container->findDefinition($service); | ||
} catch (ServiceNotFoundException $exception) { | ||
$definition = new Definition($service); | ||
|
||
$container->setDefinition($service, $definition); | ||
} | ||
|
||
$definition->addMethodCall('setContainer', [new Reference('service_container')]); | ||
$definition->setPublic(true); | ||
} | ||
} | ||
} |
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
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