custom/plugins/GbmedDocumentPaymenttarget/src/GbmedDocumentPaymenttarget.php line 32

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * gb media
  4.  * All Rights Reserved.
  5.  *
  6.  * Unauthorized copying of this file, via any medium is strictly prohibited.
  7.  * The content of this file is proprietary and confidential.
  8.  *
  9.  * @category       Shopware
  10.  * @package        Shopware_Plugins
  11.  * @subpackage     GbmedDocumentPaymenttarget
  12.  * @copyright      Copyright (c) 2020, gb media
  13.  * @license        proprietary
  14.  * @author         Giuseppe Bottino
  15.  * @link           http://www.gb-media.biz
  16.  */
  17. namespace Gbmed\DocumentPaymenttarget;
  18. require_once(__DIR__.'/../vendor/autoload.php');
  19. use Gbmed\DocumentPaymenttarget\Installer\Installer;
  20. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  21. use Shopware\Core\Framework\Plugin;
  22. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  23. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  24. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  25. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  26. use Shopware\Core\System\SystemConfig\SystemConfigService;
  27. use Symfony\Component\DependencyInjection\ContainerBuilder;
  28. class GbmedDocumentPaymenttarget extends Plugin
  29. {
  30.     /** @var Installer */
  31.     private $installer;
  32.     /**
  33.      * build container
  34.      *
  35.      * @param ContainerBuilder $container
  36.      */
  37.     public function build(ContainerBuilder $container): void
  38.     {
  39.         parent::build($container);
  40.         $container->setParameter('GbmedDocumentPaymenttarget.plugin_dir'$this->getPath());
  41.     }
  42.     /**
  43.      * install the plugin data
  44.      *
  45.      * @param InstallContext $context
  46.      * @throws \Doctrine\DBAL\DBALException
  47.      */
  48.     public function install(InstallContext $context): void
  49.     {
  50.         $this->getInstaller()->install($context);
  51.     }
  52.     /**
  53.      * update the plugin data
  54.      *
  55.      * @param UpdateContext $context
  56.      * @throws \Doctrine\DBAL\DBALException
  57.      */
  58.     public function update(UpdateContext $context): void
  59.     {
  60.         $this->getInstaller()->update($context);
  61.     }
  62.     /**
  63.      * activate plugin
  64.      *
  65.      * @param ActivateContext $context
  66.      */
  67.     public function activate(ActivateContext $context): void
  68.     {
  69.         $this->getInstaller()->activate($context);
  70.     }
  71.     /**
  72.      * removing the plugin data
  73.      *
  74.      * @param UninstallContext $context
  75.      * @throws InconsistentCriteriaIdsException
  76.      */
  77.     public function uninstall(UninstallContext $context): void
  78.     {
  79.         parent::uninstall($context);
  80.         $this->getInstaller()->uninstall($context);
  81.     }
  82.     /**
  83.      * return Installer instance
  84.      *
  85.      * @return Installer
  86.      */
  87.     private function getInstaller(): Installer
  88.     {
  89.         if (!$this->installer) {
  90.             $this->installer = new Installer(
  91.                 $this->container->get('custom_field_set.repository'),
  92.                 $this->container->get(SystemConfigService::class),
  93.                 $this->container->get('Doctrine\DBAL\Connection')
  94.             );
  95.         }
  96.         return $this->installer;
  97.     }
  98. }