custom/plugins/TonurSeoFilterLandingpages6/src/TonurSeoFilterLandingpages6.php line 9

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Tonur\SeoFilterLandingpages;
  3. use Shopware\Core\Framework\Plugin;
  4. use Doctrine\DBAL\Connection;
  5. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  6. class TonurSeoFilterLandingpages6 extends Plugin
  7. {
  8.     public function uninstall(UninstallContext $context): void
  9.     {
  10.         parent::uninstall($context);
  11.         if ($context->keepUserData()) {
  12.             return;
  13.         }
  14.         $connection $this->container->get(Connection::class);
  15.         $connection->executeUpdate('DROP TABLE IF EXISTS `repertus_seo_filter_landingpage_translation`');
  16.         $connection->executeUpdate('DROP TABLE IF EXISTS `repertus_seo_filter_landingpage_sales_channel`');
  17.         $connection->executeUpdate('DROP TABLE IF EXISTS `repertus_seo_filter_landingpage_property`');
  18.         $connection->executeUpdate('DROP TABLE IF EXISTS `repertus_seo_filter_landingpage_parameter`');
  19.         $connection->executeUpdate('DROP TABLE IF EXISTS `repertus_seo_filter_landingpage_manufacturer`');
  20.         $connection->executeUpdate('DROP TABLE IF EXISTS `repertus_seo_filter_landingpage_language`');
  21.         $connection->executeUpdate('DROP TABLE IF EXISTS `repertus_seo_filter_landingpage`');
  22.         $connection->executeUpdate('DELETE FROM `seo_url_template` WHERE `entity_name` = "repertus_seo_filter_landingpage"');
  23.         if ($this->columnAlreadyExistsInTable('landingpages''sales_channel')) {
  24.             $connection->executeUpdate('ALTER TABLE `sales_channel` DROP COLUMN `landingpages`');
  25.         }
  26.         if ($this->columnAlreadyExistsInTable('landingpages''property_group_option')) {
  27.             $connection->executeUpdate('ALTER TABLE `property_group_option` DROP COLUMN `landingpages`');
  28.         }
  29.         if ($this->columnAlreadyExistsInTable('landingpages''product_manufacturer')) {
  30.             $connection->executeUpdate('ALTER TABLE `product_manufacturer` DROP COLUMN `landingpages`');
  31.         }
  32.     }
  33.     protected function columnAlreadyExistsInTable($column$table)
  34.     {
  35.         $connection $this->container->get(Connection::class);
  36.         $result $connection->fetchAssoc("SELECT ttc.* FROM (SELECT 1 as id) tmp LEFT JOIN $table ttc ON tmp.id = ttc.id LIMIT 1");
  37.         return array_key_exists($column$result);
  38.     }
  39. }