<?php declare(strict_types=1);
namespace Acris\ProductVideo;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class AcrisProductVideoCS extends Plugin
{
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
if ($context->keepUserData()) {
return;
}
$connection = $this->container->get(Connection::class);
$connection->executeUpdate('DROP TABLE IF EXISTS `acris_product_video_translation`');
$connection->executeUpdate('DROP TABLE IF EXISTS `acris_product_video`');
$this->removeInheritance($connection, 'product', 'acrisVideos');
$this->removeInheritance($connection, 'media', 'acrisVideos');
}
protected function removeInheritance(Connection $connection, string $entity, string $propertyName): void
{
$sql = str_replace(
['#table#', '#column#'],
[$entity, $propertyName],
'ALTER TABLE `#table#` DROP `#column#`'
);
$connection->executeUpdate($sql);
}
}