custom/plugins/SwpRefundSystemSix/src/SwpRefundSystemSix.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Swp\RefundSystemSix;
  3. use Shopware\Core\Framework\Plugin;
  4. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  5. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  6. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  9. use Swp\RefundSystemSix\Utils\CustomFieldInstaller;
  10. use Swp\RefundSystemSix\Utils\InstallUninstall;
  11. class SwpRefundSystemSix extends Plugin
  12. {
  13.     public function install(InstallContext $installContext): void
  14.     {
  15.         parent::install($installContext);
  16.     }
  17.     /**
  18.      * @param UpdateContext $updateContext
  19.      * @return void
  20.      */
  21.     public function postUpdate(UpdateContext $updateContext): void
  22.     {
  23.         parent::postUpdate($updateContext);
  24.         (new CustomFieldInstaller($this->container))->activate($updateContext->getContext());
  25.     }
  26.     public function activate(ActivateContext $activateContext): void
  27.     {
  28.         (new CustomFieldInstaller($this->container))->activate($activateContext->getContext());
  29.         parent::activate($activateContext);
  30.         /*
  31.         $connection = $this->container->get(Connection::class);
  32.         $value = "INSERT INTO refund_system (id, active, created_at) VALUES
  33.                     ('".('Einweg')."', 1, '".(date('Y-m-d H:i.s').'.000')."'),
  34.                     ('".('Mehrweg')."', 1, '".(date('Y-m-d H:i.s').'.000')."'),
  35.                     ('".('Pfandfrei')."', 1, '".(date('Y-m-d H:i.s').'.000')."')
  36.                     ON DUPLICATE KEY UPDATE active = active";
  37.         $connection->executeQuery($value);
  38.         $value = "INSERT INTO refund_system_translation (refund_system_id, language_id, `name`, description, created_at) VALUES
  39.                     ('".('Einweg')."', (SELECT id FROM language WHERE name = 'Deutsch'), 'EINWEGPFAND',  'Einwegpfand', '".(date('Y-m-d H:i.s').'.000')."'),
  40.                     ('".('Mehrweg')."', (SELECT id FROM language WHERE name = 'Deutsch'), 'MEHRWEGPFAND', 'Mehrwegpfand', '".(date('Y-m-d H:i.s').'.000')."'),
  41.                     ('".('Pfandfrei')."', (SELECT id FROM language WHERE name = 'Deutsch'), 'PFANDFREI', 'Pfandfrei', '".(date('Y-m-d H:i.s').'.000')."'),
  42.                     ('".('Einweg')."', (SELECT id FROM language WHERE name = 'English'), 'ONE-WAY',  'One-way-Refund', '".(date('Y-m-d H:i.s').'.000')."'),
  43.                     ('".('Mehrweg')."', (SELECT id FROM language WHERE name = 'English'), 'REUSABLE' , 'Reusable-Refund', '".(date('Y-m-d H:i.s').'.000')."'),
  44.                     ('".('Pfandfrei')."', (SELECT id FROM language WHERE name = 'English'), 'DEPOSIT FREE', 'Deposit free', '".(date('Y-m-d H:i.s').'.000')."')
  45.                     ON DUPLICATE KEY UPDATE created_at = created_at";
  46.         $connection->executeQuery($value);
  47.         */
  48.     }
  49.     public function deactivate(DeactivateContext $deactivateContext): void
  50.     {
  51.         (new CustomFieldInstaller($this->container))->deactivate($deactivateContext->getContext());
  52.         parent::deactivate($deactivateContext);
  53.     }
  54.     public function uninstall(UninstallContext $uninstallContext): void
  55.     {
  56.         parent::uninstall($uninstallContext);
  57.         if ($uninstallContext->keepUserData()) {
  58.             return;
  59.         }
  60.         (new InstallUninstall($this->container))->uninstall($uninstallContext->getContext());
  61.         (new CustomFieldInstaller($this->container))->uninstall($uninstallContext->getContext());
  62.     }
  63. }