custom/plugins/GbmedOrderlistDocuments/src/GbmedOrderlistDocuments.php line 29

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     GbmedOrderlistDocuments
  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\OrderlistDocuments;
  18. use Doctrine\DBAL\Connection;
  19. use Gbmed\OrderlistDocuments\Installer\Handlers\DataInstaller;
  20. use Gbmed\OrderlistDocuments\Installer\Installer;
  21. use Shopware\Core\Framework\Plugin;
  22. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  23. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  24. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  25. use Symfony\Component\DependencyInjection\ContainerBuilder;
  26. class GbmedOrderlistDocuments extends Plugin
  27. {
  28.     /** @var Installer */
  29.     private $installer;
  30.     public function update(UpdateContext $context): void
  31.     {
  32.         $this->getInstaller()->update($context, [
  33.             $this->getDataInstaller()
  34.         ]);
  35.     }
  36.     public function activate(ActivateContext $context): void
  37.     {
  38.         $this->getInstaller()->activate($context, [
  39.             $this->getDataInstaller()
  40.         ]);
  41.     }
  42.     public function deactivate(DeactivateContext $context): void
  43.     {
  44.         $this->getInstaller()->deactivate($context, [
  45.             $this->getDataInstaller()
  46.         ]);
  47.     }
  48.     /**
  49.      * build container
  50.      *
  51.      * @param ContainerBuilder $container
  52.      */
  53.     public function build(ContainerBuilder $container): void
  54.     {
  55.         parent::build($container);
  56.         $container->setParameter('GbmedOrderlistDocuments.plugin_dir'$this->getPath());
  57.     }
  58.     /**
  59.      * return Installer instance
  60.      *
  61.      * @return Installer
  62.      */
  63.     private function getInstaller(): Installer
  64.     {
  65.         if (!$this->installer) {
  66.             $this->installer = new Installer();
  67.         }
  68.         return $this->installer;
  69.     }
  70.     /**
  71.      * return DataInstaller instance
  72.      *
  73.      * @return DataInstaller
  74.      */
  75.     private function getDataInstaller(): DataInstaller
  76.     {
  77.         return new DataInstaller($this->container->get(Connection::class));
  78.     }
  79. }