custom/plugins/PolPaymentPayolutionSW6/src/PolPaymentPayolutionSW6.php line 20

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace PolPaymentPayolutionSW6;
  4. use Doctrine\DBAL\Connection;
  5. use PolPaymentPayolutionSW6\Installer\ConfigurationInstaller;
  6. use PolPaymentPayolutionSW6\Installer\InstallerInterface;
  7. use PolPaymentPayolutionSW6\Installer\PaymentMethodInstaller;
  8. use PolPaymentPayolutionSW6\Installer\RuleInstaller;
  9. use Shopware\Core\Framework\Plugin;
  10. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  11. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  12. use Shopware\Core\Framework\Plugin\Util\PluginIdProvider;
  13. use Symfony\Component\Config\FileLocator;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  16. class PolPaymentPayolutionSW6 extends Plugin
  17. {
  18.     public function build(ContainerBuilder $container): void
  19.     {
  20.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/DependencyInjection'));
  21.         $loader->load('services.xml');
  22.         parent::build($container);
  23.     }
  24.     public function install(InstallContext $installContext): void
  25.     {
  26.         $this->getConfigurationInstaller()->install($installContext);
  27.         $this->getPaymentMethodInstaller()->install($installContext);
  28.         $this->getRuleInstaller()->install($installContext);
  29.     }
  30.     public function uninstall(UninstallContext $uninstallContext): void
  31.     {
  32.         $this->getConfigurationInstaller()->uninstall($uninstallContext);
  33.         $this->getPaymentMethodInstaller()->uninstall($uninstallContext);
  34.         $this->getRuleInstaller()->uninstall($uninstallContext);
  35.     }
  36.     private function getConfigurationInstaller(): InstallerInterface
  37.     {
  38.         return new ConfigurationInstaller($this->container->get(Connection::class));
  39.     }
  40.     private function getPaymentMethodInstaller(): InstallerInterface
  41.     {
  42.         return new PaymentMethodInstaller(
  43.             $this->container->get('payment_method.repository'),
  44.             $this->container->get('sales_channel.repository'),
  45.             $this->container->get('sales_channel_payment_method.repository'),
  46.             $this->container->get(PluginIdProvider::class)
  47.         );
  48.     }
  49.     private function getRuleInstaller(): InstallerInterface
  50.     {
  51.         return new RuleInstaller(
  52.             $this->container->get('rule.repository'),
  53.             $this->container->get('rule_condition.repository'),
  54.             $this->container->get('payment_method.repository'),
  55.             $this->container->get('country.repository'),
  56.             $this->container->get(PluginIdProvider::class)
  57.         );
  58.     }
  59. }