custom/plugins/GbmedDocumentBarcode/src/GbmedDocumentBarcode.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     GbmedDocumentBarcode
  12.  * @copyright      Copyright (c) 2019, gb media
  13.  * @license        proprietary
  14.  * @author         Giuseppe Bottino
  15.  * @link           http://www.gb-media.biz
  16.  */
  17. namespace Gbmed\DocumentBarcode;
  18. use Gbmed\DocumentBarcode\Installer\Installer;
  19. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  20. use Shopware\Core\Framework\Plugin;
  21. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  22. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  23. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  24. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  25. use Shopware\Core\System\SystemConfig\SystemConfigService;
  26. use Symfony\Component\DependencyInjection\ContainerBuilder;
  27. require_once(__DIR__ '/../vendor/autoload.php');
  28. class GbmedDocumentBarcode 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('GbmedDocumentBarcode.plugin_dir'$this->getPath());
  41.     }
  42.     /**
  43.      * install the plugin data
  44.      *
  45.      * @param InstallContext $context
  46.      */
  47.     public function install(InstallContext $context): void
  48.     {
  49.         $this->getInstaller()->install($context);
  50.     }
  51.     /**
  52.      * update the plugin data
  53.      *
  54.      * @param UpdateContext $context
  55.      */
  56.     public function update(UpdateContext $context): void
  57.     {
  58.         $this->getInstaller()->update($context);
  59.     }
  60.     /**
  61.      * activate plugin
  62.      *
  63.      * @param ActivateContext $context
  64.      */
  65.     public function activate(ActivateContext $context): void
  66.     {
  67.         $this->getInstaller()->activate($context);
  68.     }
  69.     /**
  70.      * removing the plugin data
  71.      *
  72.      * @param UninstallContext $context
  73.      * @throws InconsistentCriteriaIdsException
  74.      */
  75.     public function uninstall(UninstallContext $context): void
  76.     {
  77.         parent::uninstall($context);
  78.         $this->getInstaller()->uninstall($context);
  79.     }
  80.     /**
  81.      * return Installer instance
  82.      *
  83.      * @return Installer
  84.      */
  85.     private function getInstaller(): Installer
  86.     {
  87.         if (!$this->installer) {
  88.             $this->installer = new Installer(
  89.                 $this->container->get('custom_field_set.repository'),
  90.                 $this->container->get(SystemConfigService::class),
  91.                 $this->container->get('Doctrine\DBAL\Connection')
  92.             );
  93.         }
  94.         return $this->installer;
  95.     }
  96. }