<?php
declare(strict_types=1);
namespace Iwv\IwvOrdersCsvExporterV6;
if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
require_once dirname(__DIR__) . '/vendor/autoload.php';
}
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\Framework\Plugin\Context\DeactivateContext;
use Iwv\IwvOrdersCsvExporterV6\Services\Installation\IwvCustomFieldsInstallationService;
class IwvOrdersCsvExporterV6 extends Plugin
{
/**
* @param InstallContext $installContext
* @return void
*/
public function install(InstallContext $installContext): void
{
$this->getIwvCustomFieldService()->installCustomFields($installContext->getContext(), $this->isActive());
}
/**
* @param UninstallContext $uninstallContext
* @return void
*/
public function uninstall(UninstallContext $uninstallContext): void
{
if (!$uninstallContext->keepUserData()) {
$this->getIwvCustomFieldService()->uninstallCustomFields($uninstallContext->getContext());
}
}
/**
* @param UpdateContext $updateContext
* @return void
*/
public function update(UpdateContext $updateContext): void
{
$this->getIwvCustomFieldService()->installCustomFields($updateContext->getContext());
}
/**
* @param ActivateContext $activateContext
* @return void
*/
public function activate(ActivateContext $activateContext): void
{
$this->getIwvCustomFieldService()->changeCustomFieldsState(true, $activateContext->getContext());
}
/**
* @param DeactivateContext $deactivateContext
* @return void
*/
public function deactivate(DeactivateContext $deactivateContext): void
{
$this->getIwvCustomFieldService()->changeCustomFieldsState(false, $deactivateContext->getContext());
}
/**
* @return IwvCustomFieldsInstallationService
*/
protected function getIwvCustomFieldService(): IwvCustomFieldsInstallationService
{
$customFieldsSetRepository = $this->container->get('custom_field_set.repository');
return (new IwvCustomFieldsInstallationService($customFieldsSetRepository));
}
}