custom/plugins/EmzEfbExtension/src/EmzEfbExtension.php line 12

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace EmzEfbExtension;
  3. use Psr\Log\LoggerInterface;
  4. use Shopware\Core\Framework\Plugin;
  5. use EmzEfbExtension\Service\EmzCustomFieldService;
  6. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  7. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  8. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
  9. class EmzEfbExtension extends Plugin
  10. {
  11.     public function install(InstallContext $installContext): void
  12.     {
  13.         parent::install($installContext);
  14.         $this->initCustomFields($installContext);
  15.     }
  16.     public function update(UpdateContext $updateContext): void
  17.     {
  18.         parent::update($updateContext);
  19.         $this->initCustomFields($updateContext);
  20.     }
  21.     private function initCustomFields($context): void
  22.     {
  23.         /** @var EntityRepository $customFieldSetRepository */
  24.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  25.         /** @var LoggerInterface $logger */
  26.         $logger $this->container->get('logger');
  27.         $emzCustomFieldService = new EmzCustomFieldService(
  28.             $customFieldSetRepository,
  29.             $logger
  30.         );
  31.         $emzCustomFieldService->addCustomerCustomFields($context->getContext());
  32.         $emzCustomFieldService->addMediaTranslationCustomFields($context->getContext());
  33.         $emzCustomFieldService->addSalesChannelCustomFields($context->getContext());
  34.     }
  35. }