vendor/store.shopware.com/acrisvouchercs/src/AcrisVoucherCS.php line 9

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Acris\Voucher;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  6. class AcrisVoucherCS extends Plugin
  7. {
  8.     public function uninstall(UninstallContext $context): void
  9.     {
  10.         if ($context->keepUserData()) {
  11.             return;
  12.         }
  13.         $this->cleanupDatabase();
  14.     }
  15.     private function cleanupDatabase(): void
  16.     {
  17.         $connection $this->container->get(Connection::class);
  18.         $connection->executeUpdate('DROP TABLE IF EXISTS acris_promotion_code_value');
  19.         $connection->executeUpdate('DROP TABLE IF EXISTS acris_promotion_code_history');
  20.         $this->removeInheritance($connection'promotion_individual_code''acrisVoucher');
  21.         $this->removeInheritance($connection'promotion_individual_code''acrisVoucherValue');
  22.     }
  23.     protected function removeInheritance(Connection $connectionstring $entitystring $propertyName): void
  24.     {
  25.         $sql str_replace(
  26.             ['#table#''#column#'],
  27.             [$entity$propertyName],
  28.             'ALTER TABLE `#table#` DROP COLUMN `#column#`'
  29.         );
  30.         $connection->executeUpdate($sql);
  31.     }
  32. }