<?php declare(strict_types=1);
namespace Dmits\PaymentCost;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Dmits\PaymentCost\Core\Content\PaymentCost\PaymentCostDefinition;
use Composer\InstalledVersions;
class DmitsPaymentCost extends Plugin
{
public function uninstall(UninstallContext $uninstallContext): void
{
if (!$uninstallContext->keepUserData()) {
try{
$shopwareVersion = InstalledVersions::getVersion('shopware/core');
if (version_compare($shopwareVersion, '6.4', '>=')) {
$this->container->get(Connection::class)->exec('DROP TABLE IF EXISTS '.PaymentCostDefinition::ENTITY_NAME.'');
}else{
$this->container->get('Doctrine\DBAL\Connection')->executeQuery(
'DROP TABLE `'.PaymentCostDefinition::ENTITY_NAME.'`;'
);
}
} catch (OutOfBoundsException $e) {
$this->container->get(Connection::class)->exec('DROP TABLE IF EXISTS '.PaymentCostDefinition::ENTITY_NAME.'');
}
}
}
}