Skip to content

Commit

Permalink
Merge pull request #551 from Payum/builder-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup authored Aug 16, 2023
2 parents 9e1765a + 48349d1 commit a10faf1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Resources/config/payum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<defaults public="true" />

<service id="payum.builder" class="Payum\Core\PayumBuilder">
<service id="payum.builder" class="Payum\Core\PayumBuilder" public="false">
<call method="setMainRegistry">
<argument type="service" id="payum.static_registry" />
</call>
Expand Down Expand Up @@ -46,7 +46,7 @@
</call>
</service>

<service id="payum" class="Payum\Core\Payum">
<service id="payum" class="Payum\Core\Payum" lazy="true">
<factory service="payum.builder" method="getPayum" />
</service>

Expand Down
17 changes: 17 additions & 0 deletions Tests/Functional/app/AppKernelShared.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use Payum;
use Symfony;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;

class AppKernelShared extends Kernel
Expand All @@ -19,6 +21,21 @@ public function registerBundles(): array
return $bundles;
}

protected function build(ContainerBuilder $container)
{
parent::build($container);

if (Kernel::MAJOR_VERSION === 4) {
$container->addCompilerPass(new class() implements CompilerPassInterface {
public function process(ContainerBuilder $container)
{
$container->getDefinition('payum.builder')
->setPublic(true);
}
});
}
}

public function getCacheDir(): string
{
return sys_get_temp_dir() . '/PayumBundle/cache';
Expand Down

0 comments on commit a10faf1

Please sign in to comment.