vendor/store.shopware.com/moorlfoundation/src/MoorlFoundation.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace MoorlFoundation;
  3. use Doctrine\DBAL\Connection;
  4. use MoorlFoundation\Core\Service\DataService;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. class MoorlFoundation extends Plugin
  9. {
  10.     public const NAME 'MoorlFoundation';
  11.     public const DATA_CREATED_AT '2001-11-11 11:11:11.111';
  12.     public const SHOPWARE_TABLES = [];
  13.     public const PLUGIN_TABLES = [
  14.         'moorl_cms_element_config',
  15.         'moorl_location',
  16.         'moorl_location_cache',
  17.         'moorl_sorting',
  18.         'moorl_sorting_translation',
  19.         'moorl_marker',
  20.         'moorl_client',
  21.     ];
  22.     public function activate(ActivateContext $activateContext): void
  23.     {
  24.         parent::activate($activateContext);
  25.         /* @var $dataService DataService */
  26.         $dataService $this->container->get(DataService::class);
  27.         $dataService->install(self::NAME);
  28.     }
  29.     public function uninstall(UninstallContext $context): void
  30.     {
  31.         parent::uninstall($context);
  32.         if ($context->keepUserData()) {
  33.             return;
  34.         }
  35.         $this->dropTables();
  36.     }
  37.     private function dropTables(): void
  38.     {
  39.         $connection $this->container->get(Connection::class);
  40.         foreach (self::PLUGIN_TABLES as $table) {
  41.             $sql sprintf('SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `%s`;'$table);
  42.             $connection->executeStatement($sql);
  43.         }
  44.     }
  45. }