custom/plugins/RedMagnalisterSW6/src/RedMagnalisterSW6.php line 32

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /*
  3.  * 888888ba                 dP  .88888.                    dP
  4.  * 88    `8b                88 d8'   `88                   88
  5.  * 88aaaa8P' .d8888b. .d888b88 88        .d8888b. .d8888b. 88  .dP  .d8888b.
  6.  * 88   `8b. 88ooood8 88'  `88 88   YP88 88ooood8 88'  `"" 88888"   88'  `88
  7.  * 88     88 88.  ... 88.  .88 Y8.   .88 88.  ... 88.  ... 88  `8b. 88.  .88
  8.  * dP     dP `88888P' `88888P8  `88888'  `88888P' `88888P' dP   `YP `88888P'
  9.  *
  10.  *                          m a g n a l i s t e r
  11.  *                                      boost your Online-Shop
  12.  *
  13.  * -----------------------------------------------------------------------------
  14.  * (c) 2010 - 2021 RedGecko GmbH -- http://www.redgecko.de
  15.  *     Released under the MIT License (Expat)
  16.  * -----------------------------------------------------------------------------
  17.  */
  18. namespace Redgecko\Magnalister;
  19. use Doctrine\DBAL\Connection;
  20. use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexerRegistry;
  21. use Shopware\Core\Framework\DataAbstractionLayer\Indexing\Indexer\InheritanceIndexer;
  22. use Shopware\Core\Framework\DataAbstractionLayer\Indexing\MessageQueue\IndexerMessageSender;
  23. use Shopware\Core\Framework\Plugin;
  24. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  25. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  26. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  27. use Shopware\Core\Kernel;
  28. use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
  29. class RedMagnalisterSW6 extends Plugin {
  30.     public function uninstall(UninstallContext $context): void {
  31.         parent::uninstall($context);
  32.         if ($context->keepUserData()) {
  33.             return;
  34.         }
  35.         /** @var $connection Connection */
  36.         $connection $this->container->get(Connection::class);
  37.         if (method_exists($connection'fetchAll')) {
  38.             foreach ($connection->fetchAll("SHOW TABLES LIKE 'magnalister_%'") as $aTableName) {
  39.                 $sTableName current($aTableName);
  40.                 if (!empty($sTableName) && strpos($sTableName'magnalister_') !== false) {
  41.                     $connection->exec('DROP TABLE IF EXISTS ' $sTableName);
  42.                 }
  43.             }
  44.         }else{
  45.             foreach ($connection->fetchAllAssociative("SHOW TABLES LIKE 'magnalister_%'") as $aTableName) {
  46.                 $sTableName current($aTableName);
  47.                 if (!empty($sTableName) && strpos($sTableName'magnalister_') !== false) {
  48.                     $connection->exec('DROP TABLE IF EXISTS ' $sTableName);
  49.                 }
  50.             }
  51.         }
  52.     }
  53. }