custom/plugins/zenitPlatformSphere/src/zenitPlatformSphere.php line 15

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace zenit\PlatformSphere;
  3. use Shopware\Storefront\Framework\ThemeInterface;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  6. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. use Symfony\Component\Config\FileLocator;
  9. use Symfony\Component\DependencyInjection\ContainerBuilder;
  10. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  11. use zenit\PlatformSphere\Core\CustomFieldsHelper;
  12. class zenitPlatformSphere extends Plugin implements ThemeInterface
  13. {
  14.     public function getThemeConfigPath(): string
  15.     {
  16.         return 'theme.json';
  17.     }
  18.     public function install(InstallContext $installContext): void
  19.     {
  20.         parent::install($installContext);
  21.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  22.         $customFields = new CustomFieldsHelper($customFieldSetRepository);
  23.         $customFields->getCustomFields($this->container$installContext->getContext());
  24.     }
  25.     public function update(UpdateContext $updateContext): void
  26.     {
  27.         parent::update($updateContext);
  28.         if (version_compare($updateContext->getCurrentPluginVersion(), '2.9.3''<')) {
  29.             $customFieldSetRepository $this->container->get('custom_field_set.repository');
  30.             $customFields = new CustomFieldsHelper($customFieldSetRepository);
  31.             $customFields->getCustomFields($this->container$updateContext->getContext());
  32.         }
  33.     }
  34.     public function uninstall(UninstallContext $uninstallContext): void
  35.     {
  36.         parent::uninstall($uninstallContext);
  37.         if ($uninstallContext->keepUserData()) {
  38.             return;
  39.         }
  40.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  41.         $customFields = new CustomFieldsHelper($customFieldSetRepository);
  42.         $customFields->deleteCustomFields($uninstallContext->getContext());
  43.     }
  44.     /**
  45.      * @param ContainerBuilder $container
  46.      * @throws \Exception
  47.      */
  48.     public function build(ContainerBuilder $container): void
  49.     {
  50.         parent::build($container);
  51.         $loader = new XmlFileLoader($container, new FileLocator($this->getPath() . '/Core/Content/DependencyInjection'));
  52.         $loader->load('services.xml');
  53.     }
  54. }