<?php declare(strict_types=1);
namespace zenit\PlatformSphere;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Storefront\Framework\ThemeInterface;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use zenit\PlatformSphere\Core\CustomFieldsHelper;
class zenitPlatformSphere extends Plugin implements ThemeInterface
{
/**
* @var Context
*/
private $context;
public function getThemeConfigPath(): string
{
return 'theme.json';
}
public function install(InstallContext $installContext): void
{
parent::install($installContext);
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$customFields = new CustomFieldsHelper($customFieldSetRepository);
$customFields->getCustomFields($this->container, $installContext->getContext());
}
public function update(UpdateContext $updateContext): void
{
parent::update($updateContext);
if (version_compare($updateContext->getCurrentPluginVersion(), '2.6.0', '<')) {
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$customFields = new CustomFieldsHelper($customFieldSetRepository);
$customFields->getCustomFields($this->container, $updateContext->getContext());
}
}
public function uninstall(UninstallContext $uninstallContext): void
{
parent::uninstall($uninstallContext);
if ($uninstallContext->keepUserData()) {
return;
}
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$customFields = new CustomFieldsHelper($customFieldSetRepository);
$customFields->deleteCustomFields($uninstallContext->getContext());
}
/**
* @param ContainerBuilder $container
* @throws \Exception
*/
public function build(ContainerBuilder $container): void
{
parent::build($container);
$loader = new XmlFileLoader($container, new FileLocator($this->getPath() . '/Core/Content/DependencyInjection'));
$loader->load('services.xml');
}
}