custom/plugins/MaxiaTaxSwitch6/src/MaxiaTaxSwitch6.php line 16

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Maxia\MaxiaTaxSwitch6;
  3. use Maxia\MaxiaTaxSwitch6\Setup\Installer;
  4. use Maxia\MaxiaTaxSwitch6\Setup\Uninstaller;
  5. use Maxia\MaxiaTaxSwitch6\Setup\Updater;
  6. use Shopware\Core\Framework\Plugin;
  7. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  8. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  9. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  10. use Symfony\Component\Config\FileLocator;
  11. use Symfony\Component\DependencyInjection\ContainerBuilder;
  12. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  13. class MaxiaTaxSwitch6 extends Plugin
  14. {
  15.     public function build(ContainerBuilder $container): void
  16.     {
  17.         $container->setParameter('maxia.maxia_tax_switch_6.plugin_name''MaxiaTaxSwitch6');
  18.         // add 'net' parameter to the ignored http cache parameters
  19.         if ($container->hasExtension('storefront') && $container->getExtensionConfig('storefront')) {
  20.             $container->prependExtensionConfig('storefront', [
  21.                 'http_cache' => [
  22.                     'ignored_url_parameters' => ['net']
  23.                 ]
  24.             ]);
  25.         }
  26.         // load different services.xml for SW versions lower than 3.4.18
  27.         $filename 'services.xml';
  28.         try {
  29.             if (class_exists('\Composer\InstalledVersions')) {
  30.                 $shopwareVersion = \Composer\InstalledVersions::getVersion('shopware/core');
  31.                 if ($shopwareVersion && version_compare($shopwareVersion'6.4.18''<')) {
  32.                     $filename 'services-6417.xml';
  33.                 }
  34.             }
  35.         } catch (\OutOfBoundsException $e) {
  36.             // dev environment
  37.         }
  38.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection'));
  39.         $loader->load($filename);
  40.         parent::build($container);
  41.     }
  42.     /**
  43.      * {@inheritdoc}
  44.      */
  45.     public function update(UpdateContext $updateContext): void
  46.     {
  47.         parent::update($updateContext);
  48.         $updater = new Updater($this->container);
  49.         $updater->update($updateContext);
  50.     }
  51.     /**
  52.      * {@inheritdoc}
  53.      */
  54.     public function postUpdate(UpdateContext $updateContext): void
  55.     {
  56.         parent::postUpdate($updateContext);
  57.         $updater = new Updater($this->container);
  58.         $updater->postUpdate($updateContext);
  59.     }
  60.     /**
  61.      * {@inheritdoc}
  62.      */
  63.     public function install(InstallContext $installContext): void
  64.     {
  65.         parent::install($installContext);
  66.         $installer = new Installer($this->container);
  67.         $installer->install($installContext);
  68.     }
  69.     /**
  70.      * {@inheritdoc}
  71.      */
  72.     public function uninstall(UninstallContext $uninstallContext): void
  73.     {
  74.         parent::uninstall($uninstallContext);
  75.         $uninstaller = new Uninstaller($this->container);
  76.         $uninstaller->uninstall($uninstallContext);
  77.     }
  78. }