custom/plugins/FroshProductCompare/src/FroshProductCompare.php line 13

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Frosh\FroshProductCompare;
  3. use Doctrine\DBAL\Connection;
  4. use Doctrine\DBAL\DBALException;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  7. use Symfony\Component\Config\FileLocator;
  8. use Symfony\Component\DependencyInjection\ContainerBuilder;
  9. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  10. class FroshProductCompare extends Plugin
  11. {
  12.     public function build(ContainerBuilder $container): void
  13.     {
  14.         parent::build($container);
  15.         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ '/DependencyInjection/'));
  16.         $loader->load('services.xml');
  17.     }
  18.     public function uninstall(UninstallContext $uninstallContext): void
  19.     {
  20.         if ($uninstallContext->keepUserData()) {
  21.             parent::uninstall($uninstallContext);
  22.             return;
  23.         }
  24.         $this->cleanRelatedData();
  25.         parent::uninstall($uninstallContext);
  26.     }
  27.     /**
  28.      * @throws DBALException
  29.      * @throws \Doctrine\DBAL\ConnectionException
  30.      */
  31.     public function cleanRelatedData(): void
  32.     {
  33.         /** @var Connection $connection */
  34.         $connection $this->container->get(Connection::class);
  35.         $connection->executeStatement('
  36.             DROP TABLE IF EXISTS frosh_cross_selling_comparable;
  37.         ');
  38.     }
  39. }