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

Open in your IDE?
  1. <?php
  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     GbmedLabellingTyres
  12.  * @copyright      Copyright (c) 2021, gb media
  13.  * @license        proprietary
  14.  * @author         Giuseppe Bottino
  15.  * @link           http://www.gb-media.biz
  16.  */
  17. declare(strict_types=1);
  18. namespace Gbmed\LabellingTyres;
  19. use Doctrine\DBAL\DBALException;
  20. use Gbmed\LabellingTyres\Installer\Installer;
  21. use Shopware\Core\Framework\Plugin;
  22. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  23. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  24. use Doctrine\DBAL\Connection;
  25. use Shopware\Core\System\SystemConfig\SystemConfigService;
  26. class GbmedLabellingTyres 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.      * removing the plugin data
  43.      *
  44.      * @param UninstallContext $context
  45.      *
  46.      * @throws \Doctrine\DBAL\DBALException
  47.      */
  48.     public function uninstall(UninstallContext $context): void
  49.     {
  50.         $this->getInstaller()->uninstall($context);
  51.         parent::uninstall($context);
  52.     }
  53.     /**
  54.      * return Installer instance
  55.      *
  56.      * @return Installer
  57.      */
  58.     private function getInstaller(): Installer
  59.     {
  60.         if (!$this->installer) {
  61.             $this->installer = new Installer(
  62.                 $this->container->get('custom_field_set.repository'),
  63.                 $this->container->get('language.repository'),
  64.                 $this->container->get(SystemConfigService::class),
  65.                 $this->container->get(Connection::class)
  66.             );
  67.         }
  68.         return $this->installer;
  69.     }
  70. }