custom/plugins/LenzPlatformClp/src/LenzPlatformClp.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace LenzPlatformClp;
  3. use Doctrine\DBAL\Connection;
  4. use Exception;
  5. use LenzPlatformClp\Core\Content\Clp\Service\ClpImportService;
  6. use LenzPlatformClp\Core\Content\Clp\Service\ClpService;
  7. use LenzPlatformClp\Core\Content\Clp\Service\Importer\CsvImporter;
  8. use LenzPlatformClp\Core\Content\Clp\Service\UpdateClpStrategy;
  9. use Shopware\Core\Framework\Plugin;
  10. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  11. class LenzPlatformClp extends Plugin
  12. {
  13.     public function activate(Plugin\Context\ActivateContext $activateContext): void
  14.     {
  15.         /** @var ClpImportService $clpService */
  16.         $clpImportService $this->container->get(ClpImportService::class);
  17.         $clpImportService->import();
  18.     }
  19.     public function uninstall(UninstallContext $context): void
  20.     {
  21.         parent::uninstall($context);
  22.         if (!$context->keepUserData()) {
  23.             $connection $this->container->get(Connection::class);
  24.             try {
  25.                 // Drop binary column for the variants
  26.                 $connection->executeStatement('ALTER TABLE `product` DROP COLUMN `lenzPlatformClp`');
  27.             } catch(Exception $e) {
  28.                 echo "Column \"clp\" on \"product\" not deleted.\n\r";
  29.             }
  30.             $tablesToDelete = [
  31.                 'lenz_platform_clp_product',
  32.                 'lenz_platform_clp_translation',
  33.                 'lenz_platform_clp',
  34.             ];
  35.             foreach ($tablesToDelete as $table) {
  36.                 try {
  37.                     $connection->executeStatement('DROP TABLE IF EXISTS `' $table '`');
  38.                 } catch(Exception $e) {
  39.                     echo "Table \"" $table "\" not deleted.\n\r";
  40.                 }
  41.             }
  42.         }
  43.     }
  44. }