<?php declare(strict_types=1);
/**
* PremSoft
* Copyright © 2020 Premsoft - Sven Mittreiter
*
* @copyright Copyright (c) 2020, premsoft - Sven Mittreiter (http://www.premsoft.de)
* @author Sven Mittreiter <info@premsoft.de>
*/
namespace Prems\Plugin\PremsIndividualOffer6;
use Prems\Plugin\PremsIndividualOffer6\Core\Lifecycle\CustomFields;
use Prems\Plugin\PremsIndividualOffer6\Core\Lifecycle\InstallUninstall;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
class PremsIndividualOffer6 extends Plugin
{
public const OFFER_MODE_STATE = 'prems_individual_offer_offer_mode_active';
public const OFFER_MODE_EXTENSION_NAME = 'offer_mode_active';
public function install(InstallContext $context): void
{
(new InstallUninstall(
$this->container->get('mail_template_type.repository'),
$this->container->get('mail_template.repository'),
__DIR__ . '/Core/MailTemplates/',
$this->container->get(Connection::class),
$this->container->get('custom_field_set.repository'),
))->install($context);
parent::install($context);
}
public function update(UpdateContext $context): void
{
parent::update($context);
(new InstallUninstall(
$this->container->get('mail_template_type.repository'),
$this->container->get('mail_template.repository'),
__DIR__ . '/Core/MailTemplates/',
$this->container->get(Connection::class),
$this->container->get('custom_field_set.repository'),
))->update($context);
}
public function uninstall(UninstallContext $context): void
{
if ($context->keepUserData()) {
parent::uninstall($context);
return;
}
(new InstallUninstall(
$this->container->get('mail_template_type.repository'),
$this->container->get('mail_template.repository'),
__DIR__ . '/Core/MailTemplates/',
$this->container->get(Connection::class),
$this->container->get('custom_field_set.repository'),
))->uninstall($context);
$connection = $this->container->get(Connection::class);
$connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer_item`');
$connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer_messages`');
$connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer_comments`');
$connection->executeStatement('DROP TABLE IF EXISTS `prems_individual_offer`');
parent::uninstall($context);
}
}