<?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 GbmedDocumentPaymenttarget
* @copyright Copyright (c) 2020, gb media
* @license proprietary
* @author Giuseppe Bottino
* @link http://www.gb-media.biz
*/
namespace Gbmed\DocumentPaymenttarget;
require_once(__DIR__.'/../vendor/autoload.php');
use Gbmed\DocumentPaymenttarget\Installer\Installer;
use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class GbmedDocumentPaymenttarget extends Plugin
{
/** @var Installer */
private $installer;
/**
* build container
*
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->setParameter('GbmedDocumentPaymenttarget.plugin_dir', $this->getPath());
}
/**
* install the plugin data
*
* @param InstallContext $context
* @throws \Doctrine\DBAL\DBALException
*/
public function install(InstallContext $context): void
{
$this->getInstaller()->install($context);
}
/**
* update the plugin data
*
* @param UpdateContext $context
* @throws \Doctrine\DBAL\DBALException
*/
public function update(UpdateContext $context): void
{
$this->getInstaller()->update($context);
}
/**
* activate plugin
*
* @param ActivateContext $context
*/
public function activate(ActivateContext $context): void
{
$this->getInstaller()->activate($context);
}
/**
* removing the plugin data
*
* @param UninstallContext $context
* @throws InconsistentCriteriaIdsException
*/
public function uninstall(UninstallContext $context): void
{
parent::uninstall($context);
$this->getInstaller()->uninstall($context);
}
/**
* return Installer instance
*
* @return Installer
*/
private function getInstaller(): Installer
{
if (!$this->installer) {
$this->installer = new Installer(
$this->container->get('custom_field_set.repository'),
$this->container->get(SystemConfigService::class),
$this->container->get('Doctrine\DBAL\Connection')
);
}
return $this->installer;
}
}