custom/plugins/StripeShopwarePayment/src/StripeShopwarePayment.php line 31

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright (c) Pickware GmbH. All rights reserved.
  4.  * This file is part of software that is released under a proprietary license.
  5.  * You must not copy, modify, distribute, make publicly available, or execute
  6.  * its contents or parts thereof without express permission by the copyright
  7.  * holder, unless otherwise permitted by law.
  8.  */
  9. declare(strict_types=1);
  10. namespace Stripe\ShopwarePayment;
  11. use Shopware\Core\Framework\Plugin;
  12. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  13. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  14. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  15. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  16. use Shopware\Core\Framework\Plugin\Util\PluginIdProvider;
  17. use Stripe\ShopwarePayment\Installation\StripePaymentInstaller;
  18. use Stripe\ShopwarePayment\Payment\DependencyInjection\SourcePaymentConfiguratorRegistryCompilerPass;
  19. use Symfony\Component\Config\FileLocator;
  20. use Symfony\Component\DependencyInjection\ContainerBuilder;
  21. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  22. if (file_exists(__DIR__ '/../autoload-dist/vendor/autoload.php')) {
  23.     // The file does not exist if the plugin was installed via composer require of the Shopware project
  24.     require_once(__DIR__ '/../autoload-dist/vendor/autoload.php');
  25. }
  26. class StripeShopwarePayment extends Plugin
  27. {
  28.     public function build(ContainerBuilder $container): void
  29.     {
  30.         parent::build($container);
  31.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__));
  32.         $loader->load('Commands/DependencyInjection/commands.xml');
  33.         $loader->load('Config/DependencyInjection/service.xml');
  34.         $loader->load('Config/DependencyInjection/controller.xml');
  35.         $loader->load('CookieConsent/DependencyInjection/service.xml');
  36.         $loader->load('Logging/DependencyInjection/service.xml');
  37.         $loader->load('Payment/DependencyInjection/controller.xml');
  38.         $loader->load('Payment/DependencyInjection/service.xml');
  39.         $loader->load('Payment/DependencyInjection/subscriber.xml');
  40.         $loader->load('PaymentMethods/Bancontact/DependencyInjection/service.xml');
  41.         $loader->load('PaymentMethods/Card/DependencyInjection/service.xml');
  42.         $loader->load('PaymentMethods/Card/DependencyInjection/subscriber.xml');
  43.         $loader->load('PaymentMethods/DigitalWallets/DependencyInjection/controller.xml');
  44.         $loader->load('PaymentMethods/DigitalWallets/DependencyInjection/service.xml');
  45.         $loader->load('PaymentMethods/DigitalWallets/DependencyInjection/subscriber.xml');
  46.         $loader->load('PaymentMethods/Eps/DependencyInjection/service.xml');
  47.         $loader->load('PaymentMethods/Giropay/DependencyInjection/service.xml');
  48.         $loader->load('PaymentMethods/Ideal/DependencyInjection/service.xml');
  49.         $loader->load('PaymentMethods/Klarna/DependencyInjection/service.xml');
  50.         $loader->load('PaymentMethods/P24/DependencyInjection/service.xml');
  51.         $loader->load('PaymentMethods/Sepa/DependencyInjection/service.xml');
  52.         $loader->load('PaymentMethods/Sepa/DependencyInjection/subscriber.xml');
  53.         $loader->load('PaymentMethods/Sofort/DependencyInjection/service.xml');
  54.         $loader->load('Session/DependencyInjection/service.xml');
  55.         $loader->load('StripeApi/DependencyInjection/service.xml');
  56.         $loader->load('Webhook/DependencyInjection/service.xml');
  57.         $loader->load('OrderTransactionLocking/DependencyInjection/service.xml');
  58.         $composerJsonPath __DIR__ '/../composer.json';
  59.         $container->addCompilerPass(new PluginVersionCompilerPass($composerJsonPath));
  60.         $container->addCompilerPass(new SourcePaymentConfiguratorRegistryCompilerPass());
  61.     }
  62.     public function postInstall(InstallContext $installContext): void
  63.     {
  64.         $installer = new StripePaymentInstaller(
  65.             $installContext->getContext(),
  66.             $this->container->get(PluginIdProvider::class),
  67.             $this->container->get('payment_method.repository'),
  68.             $this->container->get('language.repository')
  69.         );
  70.         $installer->postInstall();
  71.         parent::postInstall($installContext);
  72.     }
  73.     public function postUpdate(UpdateContext $updateContext): void
  74.     {
  75.         $installer = new StripePaymentInstaller(
  76.             $updateContext->getContext(),
  77.             $this->container->get(PluginIdProvider::class),
  78.             $this->container->get('payment_method.repository'),
  79.             $this->container->get('language.repository')
  80.         );
  81.         $installer->postUpdate();
  82.         parent::postUpdate($updateContext);
  83.     }
  84.     public function activate(ActivateContext $activateContext): void
  85.     {
  86.         $installer = new StripePaymentInstaller(
  87.             $activateContext->getContext(),
  88.             $this->container->get(PluginIdProvider::class),
  89.             $this->container->get('payment_method.repository'),
  90.             $this->container->get('language.repository')
  91.         );
  92.         $installer->activate();
  93.         parent::activate($activateContext);
  94.     }
  95.     public function deactivate(DeactivateContext $deactivateContext): void
  96.     {
  97.         $installer = new StripePaymentInstaller(
  98.             $deactivateContext->getContext(),
  99.             $this->container->get(PluginIdProvider::class),
  100.             $this->container->get('payment_method.repository'),
  101.             $this->container->get('language.repository')
  102.         );
  103.         $installer->deactivate();
  104.         parent::deactivate($deactivateContext);
  105.     }
  106. }