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('CookieConsent/DependencyInjection/service.xml');
  35.         $loader->load('Logging/DependencyInjection/service.xml');
  36.         $loader->load('Payment/DependencyInjection/controller.xml');
  37.         $loader->load('Payment/DependencyInjection/service.xml');
  38.         $loader->load('Payment/DependencyInjection/subscriber.xml');
  39.         $loader->load('PaymentMethods/Bancontact/DependencyInjection/service.xml');
  40.         $loader->load('PaymentMethods/Card/DependencyInjection/service.xml');
  41.         $loader->load('PaymentMethods/Card/DependencyInjection/subscriber.xml');
  42.         $loader->load('PaymentMethods/DigitalWallets/DependencyInjection/controller.xml');
  43.         $loader->load('PaymentMethods/DigitalWallets/DependencyInjection/service.xml');
  44.         $loader->load('PaymentMethods/Eps/DependencyInjection/service.xml');
  45.         $loader->load('PaymentMethods/Giropay/DependencyInjection/service.xml');
  46.         $loader->load('PaymentMethods/Ideal/DependencyInjection/service.xml');
  47.         $loader->load('PaymentMethods/Klarna/DependencyInjection/service.xml');
  48.         $loader->load('PaymentMethods/P24/DependencyInjection/service.xml');
  49.         $loader->load('PaymentMethods/Sepa/DependencyInjection/service.xml');
  50.         $loader->load('PaymentMethods/Sepa/DependencyInjection/subscriber.xml');
  51.         $loader->load('PaymentMethods/Sofort/DependencyInjection/service.xml');
  52.         $loader->load('Session/DependencyInjection/service.xml');
  53.         $loader->load('StripeApi/DependencyInjection/service.xml');
  54.         $loader->load('Webhook/DependencyInjection/service.xml');
  55.         $loader->load('OrderTransactionLocking/DependencyInjection/service.xml');
  56.         $composerJsonPath __DIR__ '/../composer.json';
  57.         $container->addCompilerPass(new PluginVersionCompilerPass($composerJsonPath));
  58.         $container->addCompilerPass(new SourcePaymentConfiguratorRegistryCompilerPass());
  59.     }
  60.     public function postInstall(InstallContext $installContext): void
  61.     {
  62.         $installer = new StripePaymentInstaller(
  63.             $installContext->getContext(),
  64.             $this->container->get(PluginIdProvider::class),
  65.             $this->container->get('payment_method.repository'),
  66.             $this->container->get('language.repository')
  67.         );
  68.         $installer->postInstall();
  69.         parent::postInstall($installContext);
  70.     }
  71.     public function postUpdate(UpdateContext $updateContext): void
  72.     {
  73.         $installer = new StripePaymentInstaller(
  74.             $updateContext->getContext(),
  75.             $this->container->get(PluginIdProvider::class),
  76.             $this->container->get('payment_method.repository'),
  77.             $this->container->get('language.repository')
  78.         );
  79.         $installer->postUpdate();
  80.         parent::postUpdate($updateContext);
  81.     }
  82.     public function activate(ActivateContext $activateContext): void
  83.     {
  84.         $installer = new StripePaymentInstaller(
  85.             $activateContext->getContext(),
  86.             $this->container->get(PluginIdProvider::class),
  87.             $this->container->get('payment_method.repository'),
  88.             $this->container->get('language.repository')
  89.         );
  90.         $installer->activate();
  91.         parent::activate($activateContext);
  92.     }
  93.     public function deactivate(DeactivateContext $deactivateContext): void
  94.     {
  95.         $installer = new StripePaymentInstaller(
  96.             $deactivateContext->getContext(),
  97.             $this->container->get(PluginIdProvider::class),
  98.             $this->container->get('payment_method.repository'),
  99.             $this->container->get('language.repository')
  100.         );
  101.         $installer->deactivate();
  102.         parent::deactivate($deactivateContext);
  103.     }
  104. }