<?php declare(strict_types=1);
namespace Acris\Promotion;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class AcrisPromotionCS extends Plugin
{
public function uninstall(UninstallContext $context): void
{
if ($context->keepUserData()) {
return;
}
$this->cleanupDatabase();
}
private function cleanupDatabase(): void
{
$connection = $this->container->get(Connection::class);
$connection->executeStatement('DROP TABLE IF EXISTS acris_promotion_display');
$this->removeInheritance($connection, 'promotion', 'acrisPromotionDisplay');
}
protected function removeInheritance(Connection $connection, string $entity, string $propertyName): void
{
$sql = str_replace(
['#table#', '#column#'],
[$entity, $propertyName],
'ALTER TABLE `#table#` DROP COLUMN `#column#`'
);
$connection->executeStatement($sql);
}
}