custom/plugins/fourtwosixpaymentsurcharge/src/FourtwosixPaymentSurcharge.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Fourtwosix\PaymentSurcharge;
  4. use Doctrine\DBAL\Connection;
  5. use Fourtwosix\PaymentSurcharge\Core\Content\PaymentCost\Aggregate\PaymentCostTranslation\PaymentCostTranslationDefinition;
  6. use Fourtwosix\PaymentSurcharge\Core\Content\PaymentCost\PaymentCostDefinition;
  7. use Shopware\Core\Framework\Plugin;
  8. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  9. class FourtwosixPaymentSurcharge extends Plugin
  10. {
  11.     public function uninstall(UninstallContext $uninstallContext): void
  12.     {
  13.         if ($uninstallContext->keepUserData()) {
  14.             parent::uninstall($uninstallContext);
  15.             return;
  16.         }
  17.         $connection $this->container->get(Connection::class);
  18.         $this->dropPaymentCostTranslation($connection);
  19.         $this->dropPaymentCost($connection);
  20.     }
  21.     private function dropPaymentCostTranslation(Connection $connection): void
  22.     {
  23.         $table PaymentCostTranslationDefinition::ENTITY_NAME;
  24.         $this->dropTable($connection$table);
  25.     }
  26.     private function dropPaymentCost(Connection $connection): void
  27.     {
  28.         $table PaymentCostDefinition::ENTITY_NAME;
  29.         $this->dropTable($connection$table);
  30.     }
  31.     private function dropTable(Connection $connectionstring $table)
  32.     {
  33.         $sql = <<<SQL
  34.         DROP TABLE IF EXISTS $table;
  35.         SQL;
  36.         $connection->executeStatement($sql);
  37.     }
  38. }