<?php declare(strict_types=1);
namespace EmzEfbExtension;
use Psr\Log\LoggerInterface;
use Shopware\Core\Framework\Plugin;
use EmzEfbExtension\Service\EmzCustomFieldService;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
class EmzEfbExtension extends Plugin
{
public function install(InstallContext $installContext): void
{
parent::install($installContext);
$this->initCustomFields($installContext);
}
public function update(UpdateContext $updateContext): void
{
parent::update($updateContext);
$this->initCustomFields($updateContext);
}
private function initCustomFields($context): void
{
/** @var EntityRepository $customFieldSetRepository */
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
/** @var LoggerInterface $logger */
$logger = $this->container->get('logger');
$emzCustomFieldService = new EmzCustomFieldService(
$customFieldSetRepository,
$logger
);
$emzCustomFieldService->addCustomerCustomFields($context->getContext());
$emzCustomFieldService->addMediaTranslationCustomFields($context->getContext());
$emzCustomFieldService->addSalesChannelCustomFields($context->getContext());
}
}