custom/plugins/NetiNextExportOnEvent/src/NetiNextExportOnEvent.php line 23

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace NetInventors\NetiNextExportOnEvent;
  4. use NetInventors\NetiNextExportOnEvent\Components\Setup;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  8. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  9. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  10. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  11. if (is_file(__DIR__ '/Resources/build/vendor/autoload.php')) {
  12.     // For development
  13.     require_once __DIR__ '/Resources/build/vendor/autoload.php';
  14. } elseif (is_file(__DIR__ '/Resources/vendor/autoload.php')) {
  15.     // For production
  16.     require_once __DIR__ '/Resources/vendor/autoload.php';
  17. }
  18. class NetiNextExportOnEvent extends Plugin
  19. {
  20.     public function install(InstallContext $installContext): void
  21.     {
  22.         $installContext->setAutoMigrate(false);
  23.         $migrationCollection $installContext->getMigrationCollection();
  24.         $migrationCollection->migrateInPlace();
  25.         if (null === $this->container) {
  26.             return;
  27.         }
  28.         $setup = new Setup($this->container);
  29.         $setup->install($installContext->getContext());
  30.     }
  31.     public function update(UpdateContext $updateContext): void
  32.     {
  33.         $updateContext->setAutoMigrate(false);
  34.         $migrationCollection $updateContext->getMigrationCollection();
  35.         $migrationCollection->migrateInPlace();
  36.         if (null === $this->container) {
  37.             return;
  38.         }
  39.         $setup = new Setup($this->container);
  40.         $setup->update($updateContext->getContext());
  41.     }
  42.     public function activate(ActivateContext $activateContext): void
  43.     {
  44.         if (null === $this->container) {
  45.             return;
  46.         }
  47.         $setup = new Setup($this->container);
  48.         $setup->activate($activateContext->getContext());
  49.     }
  50.     public function deactivate(DeactivateContext $deactivateContext): void
  51.     {
  52.         if (null === $this->container) {
  53.             return;
  54.         }
  55.         $setup = new Setup($this->container);
  56.         $setup->deactivate($deactivateContext->getContext());
  57.     }
  58.     public function uninstall(UninstallContext $uninstallContext): void
  59.     {
  60.         if ($uninstallContext->keepUserData() || null === $this->container) {
  61.             return;
  62.         }
  63.         $setup = new Setup($this->container);
  64.         $setup->uninstall($uninstallContext->getContext());
  65.     }
  66. }