custom/plugins/GbmedConfigStates/src/GbmedConfigStates.php line 28

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     GbmedConfigStates
  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\ConfigStates;
  18. use Doctrine\DBAL\DBALException;
  19. use Gbmed\ConfigStates\Installer\Handlers\DataInstaller;
  20. use Gbmed\ConfigStates\Installer\Installer;
  21. use Shopware\Core\Framework\Plugin;
  22. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  23. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  24. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  25. class GbmedConfigStates extends Plugin
  26. {
  27.     /** @var Installer */
  28.     private $installer;
  29.     /**
  30.      * install the plugin data
  31.      *
  32.      * @param InstallContext $context
  33.      */
  34.     public function install(InstallContext $context): void
  35.     {
  36.         $this->getInstaller()->install($context);
  37.         parent::install($context);
  38.     }
  39.     /**
  40.      * install the plugin data
  41.      *
  42.      * @param InstallContext $context
  43.      */
  44.     public function postInstall(InstallContext $context): void
  45.     {
  46.         $this->getInstaller()->postInstall($context, [
  47.             new DataInstaller($this->container)
  48.         ]);
  49.         parent::postInstall($context);
  50.     }
  51.     /**
  52.      * update the plugin
  53.      *
  54.      * @param UpdateContext $context
  55.      */
  56.     public function update(UpdateContext $context): void
  57.     {
  58.         parent::update($context);
  59.     }
  60.     /**
  61.      * update the plugin
  62.      *
  63.      * @param UpdateContext $context
  64.      * @throws \Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException
  65.      */
  66.     public function postUpdate(UpdateContext $context): void
  67.     {
  68.         $this->getInstaller()->postUpdate($context, [
  69.             new DataInstaller($this->container)
  70.         ]);
  71.         parent::postUpdate($context);
  72.     }
  73.     /**
  74.      * removing the plugin data
  75.      *
  76.      * @param UninstallContext $context
  77.      *
  78.      * @throws DBALException
  79.      */
  80.     public function uninstall(UninstallContext $context): void
  81.     {
  82.         $this->getInstaller()->uninstall($context, [
  83.             new DataInstaller($this->container)
  84.         ]);
  85.         parent::uninstall($context);
  86.     }
  87.     /**
  88.      * return Installer instance
  89.      *
  90.      * @return Installer
  91.      */
  92.     private function getInstaller(): Installer
  93.     {
  94.         if (!$this->installer) {
  95.             $this->installer = new Installer(
  96.                 $this->container
  97.             );
  98.         }
  99.         return $this->installer;
  100.     }
  101. }