custom/plugins/ProxaDaimlerTheme/src/ProxaDaimlerTheme.php line 13

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace ProxaDaimlerTheme;
  3. use ProxaDaimlerTheme\Manager\CustomFieldManager;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Storefront\Framework\ThemeInterface;
  6. use Shopware\Core\Framework\Context;
  7. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  8. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  9. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  10. class ProxaDaimlerTheme extends Plugin implements ThemeInterface
  11. {
  12.     public function getThemeConfigPath(): string
  13.     {
  14.         return 'theme.json';
  15.     }
  16.     /**
  17.      * @param InstallContext $installContext
  18.      */
  19.     public function install(InstallContext $installContext): void
  20.     {
  21.         parent::install($installContext);
  22.         ($this->getCustomFieldManager($installContext->getContext()))->install();
  23.     }
  24.     /**
  25.      * @param UpdateContext $context
  26.      */
  27.     public function update(UpdateContext $context): void
  28.     {
  29.         parent::update($context);
  30.         ($this->getCustomFieldManager($context->getContext()))->install();
  31.     }
  32.     /**
  33.      * @param UninstallContext $uninstallContext
  34.      */
  35.     public function uninstall(UninstallContext $uninstallContext): void
  36.     {
  37.         parent::uninstall($uninstallContext);
  38.         if ($uninstallContext->keepUserData()) {
  39.             return;
  40.         }
  41.         ($this->getCustomFieldManager($uninstallContext->getContext()))->uninstall();
  42.     }
  43.     /**
  44.      * @param Context $context
  45.      * @return CustomFieldManager
  46.      */
  47.     private function getCustomFieldManager(Context $context): CustomFieldManager
  48.     {
  49.         return new CustomFieldManager(
  50.             $context,
  51.             $this->container->get('custom_field_set.repository'),
  52.             $this->container->get('snippet.repository')
  53.         );
  54.     }
  55. }