vendor/store.shopware.com/intediadoofindersw6/src/IntediaDoofinderSW6.php line 16

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Intedia\Doofinder;
  3. use Intedia\Doofinder\Core\Content\ProductExport\Service\ExportHandler;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  6. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  9. /**
  10.  * Class IntediaDoofinderSW6
  11.  * @package Intedia\Doofinder
  12.  */
  13. class IntediaDoofinderSW6 extends Plugin
  14. {
  15.     /**
  16.      * {@inheritDoc}
  17.      */
  18.     public function activate(ActivateContext $activateContext): void
  19.     {
  20.     }
  21.     /**
  22.      * {@inheritdoc}
  23.      */
  24.     public function install(InstallContext $installContext): void
  25.     {
  26.         $exportHandler = new ExportHandler($this->container->get('product_export.repository'), $this->container->get('product_stream.repository'), $this->container->get('sales_channel.repository'));
  27.         $exportHandler->createDoofinderExportsIfRequired();
  28.     }
  29.     /**
  30.      * {@inheritdoc}
  31.      */
  32.     public function update(UpdateContext $updateContext): void
  33.     {
  34.         $exportHandler = new ExportHandler($this->container->get('product_export.repository'), $this->container->get('product_stream.repository'), $this->container->get('sales_channel.repository'));
  35.         if($updateContext->getPlugin()->isActive() === true) {
  36.             switch ($updateContext->getUpdatePluginVersion()) {
  37.                 case '1.0.1':
  38.                     $exportHandler->updateDoofinderExport101();
  39.                 case '1.0.2':
  40.                     // Nothing
  41.                 case '1.0.3':
  42.                     // Nothing
  43.                 case '1.0.4':
  44.                     // Nothing
  45.                 case '1.0.5':
  46.                     $exportHandler->updateDoofinderExport105();
  47.                 case '1.0.6':
  48.                 case '1.0.7':
  49.                     // Nothing
  50.                 case '1.0.8':
  51.                     $exportHandler->updateDoofinderExport108();
  52.                 case '1.0.9':
  53.                     $exportHandler->updateDoofinderExport109();
  54.                 case '1.0.10':
  55.                     $exportHandler->createDoofinderExportsIfRequired();
  56.                 case '1.0.11':
  57.                     // Nothing
  58.                 case '1.1.0':
  59.                     $exportHandler->updateDoofinderExport110();
  60.                 case '1.1.1':
  61.                     // Nothing
  62.                 case '1.1.2':
  63.                     $exportHandler->updateDoofinderExport112();
  64.             }
  65.         } else {
  66.             throw new \Exception('Please activate the Plugin');
  67.         }
  68.     }
  69.     /**
  70.      * {@inheritdoc}
  71.      */
  72.     public function uninstall(UninstallContext $uninstallContext): void
  73.     {
  74.         if (!$uninstallContext->keepUserData()) {
  75.             $exportHandler = new ExportHandler($this->container->get('product_export.repository'), $this->container->get('product_stream.repository'), $this->container->get('sales_channel.repository'));
  76.             $exportHandler->deleteDooFinderExports();
  77.             $exportHandler->deleteDooFinderStream();
  78.         }
  79.     }
  80. }