<?php declare(strict_types=1);
/**
* gb media
* All Rights Reserved.
*
* Unauthorized copying of this file, via any medium is strictly prohibited.
* The content of this file is proprietary and confidential.
*
* @category Shopware
* @package Shopware_Plugins
* @subpackage GbmedConfigStates
* @copyright Copyright (c) 2020, gb media
* @license proprietary
* @author Giuseppe Bottino
* @link http://www.gb-media.biz
*/
namespace Gbmed\ConfigStates;
use Doctrine\DBAL\DBALException;
use Gbmed\ConfigStates\Installer\Handlers\DataInstaller;
use Gbmed\ConfigStates\Installer\Installer;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class GbmedConfigStates extends Plugin
{
/** @var Installer */
private $installer;
/**
* install the plugin data
*
* @param InstallContext $context
*/
public function install(InstallContext $context): void
{
$this->getInstaller()->install($context);
parent::install($context);
}
/**
* install the plugin data
*
* @param InstallContext $context
*/
public function postInstall(InstallContext $context): void
{
$this->getInstaller()->postInstall($context, [
new DataInstaller($this->container)
]);
parent::postInstall($context);
}
/**
* update the plugin
*
* @param UpdateContext $context
*/
public function update(UpdateContext $context): void
{
parent::update($context);
}
/**
* update the plugin
*
* @param UpdateContext $context
* @throws \Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException
*/
public function postUpdate(UpdateContext $context): void
{
$this->getInstaller()->postUpdate($context, [
new DataInstaller($this->container)
]);
parent::postUpdate($context);
}
/**
* removing the plugin data
*
* @param UninstallContext $context
*
* @throws DBALException
*/
public function uninstall(UninstallContext $context): void
{
$this->getInstaller()->uninstall($context, [
new DataInstaller($this->container)
]);
parent::uninstall($context);
}
/**
* return Installer instance
*
* @return Installer
*/
private function getInstaller(): Installer
{
if (!$this->installer) {
$this->installer = new Installer(
$this->container
);
}
return $this->installer;
}
}