custom/plugins/GbmedShoppingList/src/GbmedShoppingList.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     GbmedShoppingList
  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\ShoppingList;
  18. use Doctrine\DBAL\Connection;
  19. use Doctrine\DBAL\DBALException;
  20. use Gbmed\ShoppingList\Installer\Installer;
  21. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  22. use Shopware\Core\Framework\Plugin;
  23. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  24. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  25. use Shopware\Core\System\SystemConfig\SystemConfigService;
  26. class GbmedShoppingList extends Plugin
  27. {
  28.     /** @var Installer */
  29.     private $installer;
  30.     /**
  31.      * install the plugin data
  32.      *
  33.      * @param InstallContext $context
  34.      * @throws DBALException
  35.      */
  36.     public function install(InstallContext $context): void
  37.     {
  38.         $this->getInstaller()->install($context);
  39.         parent::install($context);
  40.     }
  41.     /**
  42.      * install the plugin data
  43.      *
  44.      * @param InstallContext $context
  45.      * @throws DBALException
  46.      */
  47.     public function postInstall(InstallContext $context): void
  48.     {
  49.         $this->getInstaller()->postInstall($context);
  50.         parent::postInstall($context);
  51.     }
  52.     /**
  53.      * removing the plugin data
  54.      *
  55.      * @param UninstallContext $context
  56.      *
  57.      * @throws DBALException
  58.      * @throws InconsistentCriteriaIdsException
  59.      */
  60.     public function uninstall(UninstallContext $context): void
  61.     {
  62.         $this->getInstaller()->uninstall($context);
  63.         parent::uninstall($context);
  64.     }
  65.     /**
  66.      * return Installer instance
  67.      *
  68.      * @return Installer
  69.      */
  70.     private function getInstaller(): Installer
  71.     {
  72.         if (!$this->installer) {
  73.             $this->installer = new Installer(
  74.                 $this->container->get('custom_field_set.repository'),
  75.                 $this->container->get('language.repository'),
  76.                 $this->container->get(SystemConfigService::class),
  77.                 $this->container->get(Connection::class)
  78.             );
  79.         }
  80.         return $this->installer;
  81.     }
  82. }