<?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 GbmedOrderlistDocuments
* @copyright Copyright (c) 2020, gb media
* @license proprietary
* @author Giuseppe Bottino
* @link http://www.gb-media.biz
*/
namespace Gbmed\OrderlistDocuments;
use Doctrine\DBAL\Connection;
use Gbmed\OrderlistDocuments\Installer\Handlers\DataInstaller;
use Gbmed\OrderlistDocuments\Installer\Installer;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class GbmedOrderlistDocuments extends Plugin
{
/** @var Installer */
private $installer;
public function update(UpdateContext $context): void
{
$this->getInstaller()->update($context, [
$this->getDataInstaller()
]);
}
public function activate(ActivateContext $context): void
{
$this->getInstaller()->activate($context, [
$this->getDataInstaller()
]);
}
public function deactivate(DeactivateContext $context): void
{
$this->getInstaller()->deactivate($context, [
$this->getDataInstaller()
]);
}
/**
* build container
*
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->setParameter('GbmedOrderlistDocuments.plugin_dir', $this->getPath());
}
/**
* return Installer instance
*
* @return Installer
*/
private function getInstaller(): Installer
{
if (!$this->installer) {
$this->installer = new Installer();
}
return $this->installer;
}
/**
* return DataInstaller instance
*
* @return DataInstaller
*/
private function getDataInstaller(): DataInstaller
{
return new DataInstaller($this->container->get(Connection::class));
}
}