<?php declare(strict_types=1);
namespace Intedia\Doofinder;
use Intedia\Doofinder\Core\Content\ProductExport\Service\ExportHandler;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
/**
* Class IntediaDoofinderSW6
* @package Intedia\Doofinder
*/
class IntediaDoofinderSW6 extends Plugin
{
/**
* {@inheritDoc}
*/
public function activate(ActivateContext $activateContext): void
{
}
/**
* {@inheritdoc}
*/
public function install(InstallContext $installContext): void
{
$exportHandler = new ExportHandler($this->container->get('product_export.repository'), $this->container->get('product_stream.repository'), $this->container->get('sales_channel.repository'));
$exportHandler->createDoofinderExportsIfRequired();
}
/**
* {@inheritdoc}
*/
public function update(UpdateContext $updateContext): void
{
$exportHandler = new ExportHandler($this->container->get('product_export.repository'), $this->container->get('product_stream.repository'), $this->container->get('sales_channel.repository'));
if($updateContext->getPlugin()->isActive() === true) {
switch ($updateContext->getUpdatePluginVersion()) {
case '1.0.1':
$exportHandler->updateDoofinderExport101();
case '1.0.2':
// Nothing
case '1.0.3':
// Nothing
case '1.0.4':
// Nothing
case '1.0.5':
$exportHandler->updateDoofinderExport105();
case '1.0.6':
case '1.0.7':
// Nothing
case '1.0.8':
$exportHandler->updateDoofinderExport108();
case '1.0.9':
$exportHandler->updateDoofinderExport109();
case '1.0.10':
$exportHandler->createDoofinderExportsIfRequired();
case '1.0.11':
// Nothing
case '1.1.0':
$exportHandler->updateDoofinderExport110();
case '1.1.1':
// Nothing
case '1.1.2':
$exportHandler->updateDoofinderExport112();
}
} else {
throw new \Exception('Please activate the Plugin');
}
}
/**
* {@inheritdoc}
*/
public function uninstall(UninstallContext $uninstallContext): void
{
if (!$uninstallContext->keepUserData()) {
$exportHandler = new ExportHandler($this->container->get('product_export.repository'), $this->container->get('product_stream.repository'), $this->container->get('sales_channel.repository'));
$exportHandler->deleteDooFinderExports();
$exportHandler->deleteDooFinderStream();
}
}
}