custom/plugins/LenzPlatformVatIdValidation/src/LenzPlatformVatIdValidation.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace LenzPlatformVatIdValidation;
  3. use Doctrine\DBAL\Connection;
  4. use Exception;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. class LenzPlatformVatIdValidation extends Plugin
  9. {
  10.     public function install(InstallContext $installContext): void
  11.     {
  12.         if(!extension_loaded('soap')) {
  13.             throw new Exception('PHP-Extension "soap" is not installed, but is a requirement for this plugin.');
  14.         }
  15.         parent::install($installContext);
  16.     }
  17.     public function uninstall(UninstallContext $uninstallContext): void
  18.     {
  19.         if(!$uninstallContext->keepUserData()) {
  20.             $connection $this->container->get(Connection::class);
  21.             $tablesToDelete = [
  22.                 'lenz_platform_vat_id_validation_result',
  23.             ];
  24.             foreach ($tablesToDelete as $table) {
  25.                 try {
  26.                     $connection->executeStatement('DROP TABLE IF EXISTS `' $table '`');
  27.                 } catch(Exception $e) {
  28.                     echo "Table \"" $table "\" not deleted.\n\r";
  29.                 }
  30.             }
  31.         }
  32.     }
  33. }