<?php declare(strict_types=1);
namespace Mrpix\ShoppingCity;
use Doctrine\DBAL\Connection;
use Mrpix\ShoppingCity\Core\Content\SellerEvent\SellerEventDefinition;
use Mrpix\ShoppingCity\Core\Content\SellerInformation\SellerInformationDefinition;
use Mrpix\ShoppingCity\Core\Content\SellerNews\SellerNewsDefinition;
use Mrpix\ShoppingCity\Core\Content\SellerProperty\SellerPropertyDefinition;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class MrpixShoppingCity extends Plugin
{
private const TABLE_NAMES = [
SellerEventDefinition::ENTITY_NAME,
SellerInformationDefinition::ENTITY_NAME,
SellerNewsDefinition::ENTITY_NAME,
SellerPropertyDefinition::ENTITY_NAME,
];
public function uninstall(UninstallContext $uninstallContext): void
{
if ($uninstallContext->keepUserData()) {
return;
}
$this->removeTables();
parent::uninstall($uninstallContext);
}
private function removeTables(): void
{
/** @var Connection $connection */
$connection = $this->container->get(Connection::class);
foreach (self::TABLE_NAMES as $table) {
$connection->executeStatement('DROP TABLE ' . $table);
}
}
}