custom/plugins/TpayShopwarePayment/src/TpayShopwarePayment.php line 34

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * @copyright 2020 Tpay Krajowy Integrator Płatności S.A. <https://tpay.com/>
  4.  *
  5.  * @author    Jakub Medyński <jme@crehler.com>
  6.  * @support   Tpay <pt@tpay.com>
  7.  * @created   23 kwi 2020
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Tpay\ShopwarePayment;
  13. use Doctrine\DBAL\Connection;
  14. use Shopware\Core\Framework\Plugin;
  15. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  16. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  17. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  18. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  19. use Shopware\Core\Framework\Plugin\Util\PluginIdProvider;
  20. use Symfony\Component\Config\FileLocator;
  21. use Symfony\Component\DependencyInjection\ContainerBuilder;
  22. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  23. use Tpay\ShopwarePayment\Util\Lifecycle\ActivateDeactivate;
  24. use Tpay\ShopwarePayment\Util\Lifecycle\InstallUninstall;
  25. use tpayLibs\src\_class_tpay\Utilities\Util;
  26. // SWAG-133666
  27. if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
  28.     require_once dirname(__DIR__) . '/vendor/autoload.php';
  29. }
  30. class TpayShopwarePayment extends Plugin
  31. {
  32.     public const ORDER_TRANSACTION_CUSTOM_FIELDS_TPAY_TRANSACTION_ID 'tpay_shopware_payment_transaction_id';
  33.     public const CUSTOMER_CUSTOM_FIELDS_TPAY_SELECTED_BANK 'tpay_default_payment_selected_bank';
  34.     /**
  35.      * @var ActivateDeactivate
  36.      */
  37.     private $activateDeactivate;
  38.     /**
  39.      * @Required
  40.      *
  41.      * @param ActivateDeactivate $activateDeactivate
  42.      */
  43.     public function setActivateDeactivate(ActivateDeactivate $activateDeactivate): void
  44.     {
  45.         $this->activateDeactivate $activateDeactivate;
  46.     }
  47.     public function build(ContainerBuilder $container): void
  48.     {
  49.         parent::build($container);
  50.         
  51.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection/'));
  52.         $loader->load('util.xml');
  53.         $loader->load('payment.xml');
  54.         $loader->load('config.xml');
  55.         $loader->load('subscriber.xml');
  56.         $loader->load('component.xml');
  57.         $loader->load('webhook.xml');
  58.         $loader->load('entity.xml');
  59.     }
  60.     public function install(InstallContext $installContext): void
  61.     {
  62.         (new InstallUninstall(
  63.             $this->container->get(Connection::class),
  64.             $this->container->get('payment_method.repository'),
  65.             $this->container->get('rule.repository'),
  66.             $this->container->get('currency.repository'),
  67.             $this->container->get('language.repository'),
  68.             $this->container->get(PluginIdProvider::class),
  69.             \get_class($this)))->install($installContext->getContext());
  70.     }
  71.     public function uninstall(UninstallContext $uninstallContext): void
  72.     {
  73.         (new InstallUninstall(
  74.             $this->container->get(Connection::class),
  75.             $this->container->get('payment_method.repository'),
  76.             $this->container->get('rule.repository'),
  77.             $this->container->get('currency.repository'),
  78.             $this->container->get('language.repository'),
  79.             $this->container->get(PluginIdProvider::class),
  80.             \get_class($this)))->uninstall($uninstallContext);
  81.     }
  82.     public function activate(ActivateContext $activateContext): void
  83.     {
  84.         $this->activateDeactivate->activate($activateContext->getContext());
  85.     }
  86.     public function deactivate(DeactivateContext $deactivateContext): void
  87.     {
  88.         $this->activateDeactivate->deactivate($deactivateContext->getContext());
  89.     }
  90. }