Remove possibility to add Stripe as a payment method when package is missing

This commit is contained in:
Jakub Tobiasz 2023-02-10 16:27:19 +01:00
parent 833c89118f
commit df124bc5ff
No known key found for this signature in database
GPG key ID: 6434250CB3525233
3 changed files with 36 additions and 1 deletions

View file

@ -28,7 +28,8 @@
"HWI\\Bundle\\OAuthBundle\\Security\\Core\\User\\OAuthAwareUserProviderInterface",
"League\\Flysystem\\FilesystemOperator",
"Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface",
"PHPUnit\\Framework\\ExpectationFailedException"
"PHPUnit\\Framework\\ExpectationFailedException",
"Stripe\\Stripe"
],
"php-core-extensions" : [
"Core",

View file

@ -0,0 +1,32 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\PayumBundle\DependencyInjection\Compiler;
use Stripe\Stripe;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
final class UnregisterStripeGatewayTypePass implements CompilerPassInterface
{
private const STRIPE_GATEWAY_TYPE_SERVICE_ID = 'sylius.form.type.gateway_configuration.stripe';
public function process(ContainerBuilder $container)
{
if (class_exists(Stripe::class)) {
return;
}
$container->removeDefinition(self::STRIPE_GATEWAY_TYPE_SERVICE_ID);
}
}

View file

@ -15,6 +15,7 @@ namespace Sylius\Bundle\PayumBundle;
use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\InjectContainerIntoControllersPass;
use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\RegisterGatewayConfigTypePass;
use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\UnregisterStripeGatewayTypePass;
use Sylius\Bundle\PayumBundle\DependencyInjection\Compiler\UseTweakedDoctrineStoragePass;
use Sylius\Bundle\ResourceBundle\AbstractResourceBundle;
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
@ -36,5 +37,6 @@ final class SyliusPayumBundle extends AbstractResourceBundle
$container->addCompilerPass(new InjectContainerIntoControllersPass());
$container->addCompilerPass(new RegisterGatewayConfigTypePass());
$container->addCompilerPass(new UseTweakedDoctrineStoragePass());
$container->addCompilerPass(new UnregisterStripeGatewayTypePass(), priority: 128);
}
}