<?php declare(strict_types=1);
namespace Maxia\MaxiaTaxSwitch6;
use Maxia\MaxiaTaxSwitch6\Setup\Installer;
use Maxia\MaxiaTaxSwitch6\Setup\Uninstaller;
use Maxia\MaxiaTaxSwitch6\Setup\Updater;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class MaxiaTaxSwitch6 extends Plugin
{
public function build(ContainerBuilder $container): void
{
$container->setParameter('maxia.maxia_tax_switch_6.plugin_name', 'MaxiaTaxSwitch6');
// add 'net' parameter to the ignored http cache parameters
if ($container->hasExtension('storefront') && $container->getExtensionConfig('storefront')) {
$container->prependExtensionConfig('storefront', [
'http_cache' => [
'ignored_url_parameters' => ['net']
]
]);
}
// load different services.xml for SW versions lower than 3.4.18
$filename = 'services.xml';
try {
if (class_exists('\Composer\InstalledVersions')) {
$shopwareVersion = \Composer\InstalledVersions::getVersion('shopware/core');
if ($shopwareVersion && version_compare($shopwareVersion, '6.4.18', '<')) {
$filename = 'services-6417.xml';
}
}
} catch (\OutOfBoundsException $e) {
// dev environment
}
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/DependencyInjection'));
$loader->load($filename);
parent::build($container);
}
/**
* {@inheritdoc}
*/
public function update(UpdateContext $updateContext): void
{
parent::update($updateContext);
$updater = new Updater($this->container);
$updater->update($updateContext);
}
/**
* {@inheritdoc}
*/
public function postUpdate(UpdateContext $updateContext): void
{
parent::postUpdate($updateContext);
$updater = new Updater($this->container);
$updater->postUpdate($updateContext);
}
/**
* {@inheritdoc}
*/
public function install(InstallContext $installContext): void
{
parent::install($installContext);
$installer = new Installer($this->container);
$installer->install($installContext);
}
/**
* {@inheritdoc}
*/
public function uninstall(UninstallContext $uninstallContext): void
{
parent::uninstall($uninstallContext);
$uninstaller = new Uninstaller($this->container);
$uninstaller->uninstall($uninstallContext);
}
}