<?php
declare(strict_types=1);
namespace NetInventors\NetiNextExportOnEvent;
use NetInventors\NetiNextExportOnEvent\Components\Setup;
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\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
if (is_file(__DIR__ . '/Resources/build/vendor/autoload.php')) {
// For development
require_once __DIR__ . '/Resources/build/vendor/autoload.php';
} elseif (is_file(__DIR__ . '/Resources/vendor/autoload.php')) {
// For production
require_once __DIR__ . '/Resources/vendor/autoload.php';
}
class NetiNextExportOnEvent extends Plugin
{
public function install(InstallContext $installContext): void
{
$installContext->setAutoMigrate(false);
$migrationCollection = $installContext->getMigrationCollection();
$migrationCollection->migrateInPlace();
if (null === $this->container) {
return;
}
$setup = new Setup($this->container);
$setup->install($installContext->getContext());
}
public function update(UpdateContext $updateContext): void
{
$updateContext->setAutoMigrate(false);
$migrationCollection = $updateContext->getMigrationCollection();
$migrationCollection->migrateInPlace();
if (null === $this->container) {
return;
}
$setup = new Setup($this->container);
$setup->update($updateContext->getContext());
}
public function activate(ActivateContext $activateContext): void
{
if (null === $this->container) {
return;
}
$setup = new Setup($this->container);
$setup->activate($activateContext->getContext());
}
public function deactivate(DeactivateContext $deactivateContext): void
{
if (null === $this->container) {
return;
}
$setup = new Setup($this->container);
$setup->deactivate($deactivateContext->getContext());
}
public function uninstall(UninstallContext $uninstallContext): void
{
if ($uninstallContext->keepUserData() || null === $this->container) {
return;
}
$setup = new Setup($this->container);
$setup->uninstall($uninstallContext->getContext());
}
}