custom/plugins/MoorlFoundation/src/MoorlFoundation.php line 9

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace MoorlFoundation;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  6. class MoorlFoundation extends Plugin
  7. {
  8.     public const NAME 'MoorlFoundation';
  9.     public const DATA_CREATED_AT '2001-11-11 11:11:11.111';
  10.     public const PLUGIN_TABLES = [
  11.         'moorl_cms_element_config',
  12.         'moorl_location',
  13.         'moorl_sorting',
  14.         'moorl_sorting_translation',
  15.     ];
  16.     public function uninstall(UninstallContext $context): void
  17.     {
  18.         parent::uninstall($context);
  19.         if ($context->keepUserData()) {
  20.             return;
  21.         }
  22.         $this->dropTables();
  23.     }
  24.     private function dropTables(): void
  25.     {
  26.         $connection $this->container->get(Connection::class);
  27.         foreach (self::PLUGIN_TABLES as $table) {
  28.             $sql sprintf('SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `%s`;'$table);
  29.             $connection->executeUpdate($sql);
  30.         }
  31.     }
  32. }