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

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace S360Experts;
  3. use Shopware\Core\Framework\Plugin;
  4. use Doctrine\DBAL\Connection;
  5. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  6. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  7. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  8. use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexerRegistry;
  9. class S360Experts extends Plugin
  10. {
  11.     public function activate(ActivateContext $activateContext): void
  12.     {
  13.         $entityIndexerRegistry $this->container->get(EntityIndexerRegistry::class);
  14.         $entityIndexerRegistry->sendIndexingMessage(['product.indexer']);
  15.         $entityIndexerRegistry $this->container->get(EntityIndexerRegistry::class);
  16.         $entityIndexerRegistry->sendIndexingMessage(['category.indexer']);
  17.     }
  18.     public function install(InstallContext $installContext): void
  19.     {
  20.         parent::install($installContext);
  21.     }
  22.     public function uninstall(UninstallContext $uninstallContext): void
  23.     {
  24.         if ($uninstallContext->keepUserData()) {
  25.             return;
  26.         }
  27.         $this->removeUserData();
  28.     }
  29.     private function removeUserData()
  30.     {
  31.         $connection $this->container->get(Connection::class);
  32.         $connection->executeUpdate('ALTER TABLE `product` DROP COLUMN `experts`');
  33.         $connection->executeUpdate('ALTER TABLE `category` DROP COLUMN `experts`');
  34.         
  35.         $connection->executeQuery('DROP TABLE IF EXISTS `s360_expert_category`');
  36.         $connection->executeQuery('DROP TABLE IF EXISTS `s360_expert_product`');
  37.         $connection->executeQuery('DROP TABLE IF EXISTS `s360_experts_expert_translation`');
  38.         $connection->executeQuery('DROP TABLE IF EXISTS `s360_experts_expert`');
  39.     }
  40. }