custom/plugins/PayonePayment/src/PayonePayment.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace PayonePayment;
  4. use Doctrine\DBAL\Connection;
  5. use PayonePayment\Installer\ConfigInstaller;
  6. use PayonePayment\Installer\CustomFieldInstaller;
  7. use PayonePayment\Installer\PaymentMethodInstaller;
  8. use PayonePayment\Installer\RuleInstaller\RuleInstallerSecureInvoice;
  9. use Shopware\Core\Framework\Plugin;
  10. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  11. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  12. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  13. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  14. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  15. use Symfony\Component\Config\FileLocator;
  16. use Symfony\Component\DependencyInjection\ContainerBuilder;
  17. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  18. class PayonePayment extends Plugin
  19. {
  20.     public function build(ContainerBuilder $container): void
  21.     {
  22.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection'));
  23.         $loader->load('services.xml');
  24.         parent::build($container);
  25.     }
  26.     public function install(InstallContext $context): void
  27.     {
  28.         (new ConfigInstaller($this->container))->install($context);
  29.         (new CustomFieldInstaller($this->container))->install($context);
  30.         (new PaymentMethodInstaller($this->container))->install($context);
  31.         (new RuleInstallerSecureInvoice($this->container))->install($context);
  32.     }
  33.     public function update(UpdateContext $context): void
  34.     {
  35.         (new ConfigInstaller($this->container))->update($context);
  36.         (new CustomFieldInstaller($this->container))->update($context);
  37.         (new PaymentMethodInstaller($this->container))->update($context);
  38.         (new RuleInstallerSecureInvoice($this->container))->update($context);
  39.     }
  40.     public function activate(ActivateContext $context): void
  41.     {
  42.         (new ConfigInstaller($this->container))->activate($context);
  43.         (new CustomFieldInstaller($this->container))->activate($context);
  44.         (new PaymentMethodInstaller($this->container))->activate($context);
  45.         (new RuleInstallerSecureInvoice($this->container))->activate($context);
  46.     }
  47.     public function deactivate(DeactivateContext $context): void
  48.     {
  49.         (new ConfigInstaller($this->container))->deactivate($context);
  50.         (new CustomFieldInstaller($this->container))->deactivate($context);
  51.         (new PaymentMethodInstaller($this->container))->deactivate($context);
  52.         (new RuleInstallerSecureInvoice($this->container))->deactivate($context);
  53.     }
  54.     public function uninstall(UninstallContext $context): void
  55.     {
  56.         (new ConfigInstaller($this->container))->uninstall($context);
  57.         (new CustomFieldInstaller($this->container))->uninstall($context);
  58.         (new PaymentMethodInstaller($this->container))->uninstall($context);
  59.         (new RuleInstallerSecureInvoice($this->container))->uninstall($context);
  60.         if ($context->keepUserData()) {
  61.             return;
  62.         }
  63.         /** @var Connection $connection */
  64.         $connection $this->container->get(Connection::class);
  65.         $connection->exec('DROP TABLE payone_payment_card');
  66.         $connection->exec('DROP TABLE payone_payment_redirect');
  67.         $connection->exec('DROP TABLE payone_payment_mandate');
  68.     }
  69. }