vendor/store.shopware.com/premsindividualoffer6/src/PremsIndividualOffer6.php line 20

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * PremSoft
  4.  * Copyright © 2020 Premsoft - Sven Mittreiter
  5.  *
  6.  * @copyright  Copyright (c) 2020, premsoft - Sven Mittreiter (http://www.premsoft.de)
  7.  * @author     Sven Mittreiter <info@premsoft.de>
  8.  */
  9. namespace Prems\Plugin\PremsIndividualOffer6;
  10. use Prems\Plugin\PremsIndividualOffer6\Core\Lifecycle\CustomFields;
  11. use Prems\Plugin\PremsIndividualOffer6\Core\Lifecycle\InstallUninstall;
  12. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  13. use Shopware\Core\Framework\Plugin;
  14. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  15. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  16. use Doctrine\DBAL\Connection;
  17. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  18. class PremsIndividualOffer6 extends Plugin
  19. {
  20.     public const OFFER_MODE_STATE 'prems_individual_offer_offer_mode_active';
  21.     public const OFFER_MODE_EXTENSION_NAME 'offer_mode_active';
  22.     public function install(InstallContext $context): void
  23.     {
  24.         (new InstallUninstall(
  25.             $this->container->get('mail_template_type.repository'),
  26.             $this->container->get('mail_template.repository'),
  27.             __DIR__ '/Core/MailTemplates/',
  28.             $this->container->get(Connection::class),
  29.             $this->container->get('custom_field_set.repository'),
  30.         ))->install($context);
  31.         parent::install($context);
  32.     }
  33.     public function update(UpdateContext $context): void
  34.     {
  35.         parent::update($context);
  36.         (new InstallUninstall(
  37.             $this->container->get('mail_template_type.repository'),
  38.             $this->container->get('mail_template.repository'),
  39.             __DIR__ '/Core/MailTemplates/',
  40.             $this->container->get(Connection::class),
  41.             $this->container->get('custom_field_set.repository'),
  42.         ))->update($context);
  43.     }
  44.     public function uninstall(UninstallContext $context): void
  45.     {
  46.         if ($context->keepUserData()) {
  47.             parent::uninstall($context);
  48.             return;
  49.         }
  50.         (new InstallUninstall(
  51.             $this->container->get('mail_template_type.repository'),
  52.             $this->container->get('mail_template.repository'),
  53.             __DIR__ '/Core/MailTemplates/',
  54.             $this->container->get(Connection::class),
  55.             $this->container->get('custom_field_set.repository'),
  56.         ))->uninstall($context);
  57.         $connection $this->container->get(Connection::class);
  58.         $connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer_item`');
  59.         $connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer_messages`');
  60.         $connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer_comments`');
  61.         $connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer`');
  62.         parent::uninstall($context);
  63.     }
  64. }