<?php declare(strict_types=1);
namespace Dtgs\DeliveryDate;
use Dtgs\DeliveryDate\Components\Helper\CustomFieldHelper;
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\ContainerInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class DtgsDeliveryDateSw6 extends Plugin
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/DependencyInjection/'));
$loader->load('helper.xml');
$loader->load('subscriber.xml');
}
/**
* @param InstallContext $context
*/
public function install(InstallContext $context): void
{
$customFieldHelper = new CustomFieldHelper($this->container);
$customFieldHelper->installOrderField();
#$customFieldHelper->installDispatchFields();
parent::install($context);
}
public function update(UpdateContext $updateContext): void
{
$customFieldHelper = new CustomFieldHelper($this->container);
/*if(version_compare($updateContext->getCurrentPluginVersion(), '6.1.0', '<')) {
$customFieldHelper->installDispatchFields();
}*/
parent::update($updateContext);
}
/**
* @param UninstallContext $context
*/
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
if ($context->keepUserData()) {
return;
}
$customFieldHelper = new CustomFieldHelper($this->container);
$customFieldHelper->uninstallCustomFields();
}
}