<?php
declare(strict_types=1);
namespace PolPaymentPayolutionSW6;
use Doctrine\DBAL\Connection;
use PolPaymentPayolutionSW6\Installer\ConfigurationInstaller;
use PolPaymentPayolutionSW6\Installer\InstallerInterface;
use PolPaymentPayolutionSW6\Installer\PaymentMethodInstaller;
use PolPaymentPayolutionSW6\Installer\RuleInstaller;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Util\PluginIdProvider;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class PolPaymentPayolutionSW6 extends Plugin
{
public function build(ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/DependencyInjection'));
$loader->load('services.xml');
parent::build($container);
}
public function install(InstallContext $installContext): void
{
$this->getConfigurationInstaller()->install($installContext);
$this->getPaymentMethodInstaller()->install($installContext);
$this->getRuleInstaller()->install($installContext);
}
public function uninstall(UninstallContext $uninstallContext): void
{
$this->getConfigurationInstaller()->uninstall($uninstallContext);
$this->getPaymentMethodInstaller()->uninstall($uninstallContext);
$this->getRuleInstaller()->uninstall($uninstallContext);
}
private function getConfigurationInstaller(): InstallerInterface
{
return new ConfigurationInstaller($this->container->get(Connection::class));
}
private function getPaymentMethodInstaller(): InstallerInterface
{
return new PaymentMethodInstaller(
$this->container->get('payment_method.repository'),
$this->container->get('sales_channel.repository'),
$this->container->get('sales_channel_payment_method.repository'),
$this->container->get(PluginIdProvider::class)
);
}
private function getRuleInstaller(): InstallerInterface
{
return new RuleInstaller(
$this->container->get('rule.repository'),
$this->container->get('rule_condition.repository'),
$this->container->get('payment_method.repository'),
$this->container->get('country.repository'),
$this->container->get(PluginIdProvider::class)
);
}
}