<?php declare(strict_types=1);
namespace LenzPlatformVatIdValidation;
use Doctrine\DBAL\Connection;
use Exception;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class LenzPlatformVatIdValidation extends Plugin
{
public function install(InstallContext $installContext): void
{
if(!extension_loaded('soap')) {
throw new Exception('PHP-Extension "soap" is not installed, but is a requirement for this plugin.');
}
parent::install($installContext);
}
public function uninstall(UninstallContext $uninstallContext): void
{
if(!$uninstallContext->keepUserData()) {
$connection = $this->container->get(Connection::class);
$tablesToDelete = [
'lenz_platform_vat_id_validation_result',
];
foreach ($tablesToDelete as $table) {
try {
$connection->executeStatement('DROP TABLE IF EXISTS `' . $table . '`');
} catch(Exception $e) {
echo "Table \"" . $table . "\" not deleted.\n\r";
}
}
}
}
}