custom/plugins/DtgsDeliveryDateSw6/src/DtgsDeliveryDateSw6.php line 15

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Dtgs\DeliveryDate;
  3. use Dtgs\DeliveryDate\Components\Helper\CustomFieldHelper;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  6. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  7. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  8. use Symfony\Component\Config\FileLocator;
  9. use Symfony\Component\DependencyInjection\ContainerBuilder;
  10. use Symfony\Component\DependencyInjection\ContainerInterface;
  11. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  12. class DtgsDeliveryDateSw6 extends Plugin
  13. {
  14.     /**
  15.      * {@inheritdoc}
  16.      */
  17.     public function build(ContainerBuilder $container): void
  18.     {
  19.         parent::build($container);
  20.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection/'));
  21.         $loader->load('helper.xml');
  22.         $loader->load('subscriber.xml');
  23.     }
  24.     /**
  25.      * @param InstallContext $context
  26.      */
  27.     public function install(InstallContext $context): void
  28.     {
  29.         $customFieldHelper = new CustomFieldHelper($this->container);
  30.         $customFieldHelper->installOrderField();
  31.         #$customFieldHelper->installDispatchFields();
  32.         parent::install($context);
  33.     }
  34.     public function update(UpdateContext $updateContext): void
  35.     {
  36.         $customFieldHelper = new CustomFieldHelper($this->container);
  37.         /*if(version_compare($updateContext->getCurrentPluginVersion(), '6.1.0', '<')) {
  38.             $customFieldHelper->installDispatchFields();
  39.         }*/
  40.         parent::update($updateContext);
  41.     }
  42.     /**
  43.      * @param UninstallContext $context
  44.      */
  45.     public function uninstall(UninstallContext $context): void
  46.     {
  47.         parent::uninstall($context);
  48.         if ($context->keepUserData()) {
  49.             return;
  50.         }
  51.         $customFieldHelper = new CustomFieldHelper($this->container);
  52.         $customFieldHelper->uninstallCustomFields();
  53.     }
  54. }