custom/plugins/HuebertAccountAttributes/src/HuebertAccountAttributes.php line 12

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace HuebertAccountAttributes;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Indexing\EntityIndexerRegistry;
  5. use Shopware\Core\Framework\Plugin;
  6. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  8. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  9. class HuebertAccountAttributes extends Plugin
  10. {
  11.     public function activate(ActivateContext $activateContext): void
  12.     {
  13.         $registry $this->container->get(EntityIndexerRegistry::class);
  14.         $registry->sendIndexingMessage(['media.indexer']);
  15.     }
  16.     public function postInstall(InstallContext $installContext): void
  17.     {
  18.         $connection $this->container->get(Connection::class);
  19.         $connection->executeUpdate('UPDATE media SET download = id WHERE download IS NULL');
  20.     }
  21.     public function uninstall(UninstallContext $uninstallContext): void
  22.     {
  23.         if($uninstallContext->keepUserData()) {
  24.             return;
  25.         }
  26.         $connection $this->container->get(Connection::class);
  27.         $connection->executeUpdate('DROP TRIGGER IF EXISTS `update_media_download`');
  28.         $connection->executeUpdate('ALTER TABLE media DROP COLUMN download;');
  29.         $connection->executeUpdate('DROP TABLE sysea_download_media;');
  30.         $connection->executeUpdate('DROP TABLE sysea_download_translation;');
  31.         $connection->executeUpdate('DROP TABLE sysea_download;');
  32.     }
  33. }