<?php declare(strict_types=1);
namespace ProxaDaimlerTheme;
use ProxaDaimlerTheme\Manager\CustomFieldManager;
use Shopware\Core\Framework\Plugin;
use Shopware\Storefront\Framework\ThemeInterface;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class ProxaDaimlerTheme extends Plugin implements ThemeInterface
{
public function getThemeConfigPath(): string
{
return 'theme.json';
}
/**
* @param InstallContext $installContext
*/
public function install(InstallContext $installContext): void
{
parent::install($installContext);
($this->getCustomFieldManager($installContext->getContext()))->install();
}
/**
* @param UpdateContext $context
*/
public function update(UpdateContext $context): void
{
parent::update($context);
($this->getCustomFieldManager($context->getContext()))->install();
}
/**
* @param UninstallContext $uninstallContext
*/
public function uninstall(UninstallContext $uninstallContext): void
{
parent::uninstall($uninstallContext);
if ($uninstallContext->keepUserData()) {
return;
}
($this->getCustomFieldManager($uninstallContext->getContext()))->uninstall();
}
/**
* @param Context $context
* @return CustomFieldManager
*/
private function getCustomFieldManager(Context $context): CustomFieldManager
{
return new CustomFieldManager(
$context,
$this->container->get('custom_field_set.repository'),
$this->container->get('snippet.repository')
);
}
}