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

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace zenit\PlatformFeaturesBar;
  3. use Shopware\Core\Framework\Plugin;
  4. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  5. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  6. use Shopware\Core\Framework\Context;
  7. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  8. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  9. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter;
  10. use Shopware\Core\System\SystemConfig\SystemConfigService;
  11. class zenitPlatformFeaturesBar extends Plugin
  12. {
  13.     public function install(InstallContext $installContext): void
  14.     {
  15.         $this->addDefaultConfiguration();
  16.         parent::install($installContext);
  17.     }
  18.     public function uninstall(UninstallContext $uninstallContext): void
  19.     {
  20.         if ($uninstallContext->keepUserData()) {
  21.             parent::uninstall($uninstallContext);
  22.             return;
  23.         }
  24.         parent::uninstall($uninstallContext);
  25.     }
  26.     private function addDefaultConfiguration(): void
  27.     {
  28.         $this->setValue('active'true);
  29.         $this->setValue('allowedControllers', []);
  30.         $this->setValue('columnCount''4');
  31.         $this->setValue('statemanagerTop', ['d-block d-sm-none''d-sm-block d-md-none''d-md-block d-lg-none''d-lg-block d-xl-none''d-xl-block']);
  32.         $this->setValue('positionTop''headerTop');
  33.         $this->setValue('statemanagerBottom', ['d-block d-sm-none''d-sm-block d-md-none''d-md-block d-lg-none''d-lg-block d-xl-none''d-xl-block']);
  34.         $this->setValue('positionBottom''false'); // string!
  35.         $this->setValue('icon1''check');
  36.         $this->setValue('text1''Lorem ipsum dolor sit amet');
  37.         $this->setValue('text1Slide');
  38.         $this->setValue('text1Link');
  39.         $this->setValue('text1LinkTarget''_self');
  40.         $this->setValue('text1Statemanager', ['d-block d-sm-none''d-sm-block d-md-none''d-md-block d-lg-none''d-lg-block d-xl-none''d-xl-block']);
  41.         $this->setValue('icon2''check');
  42.         $this->setValue('text2''Lorem ipsum dolor sit amet');
  43.         $this->setValue('text2Slide');
  44.         $this->setValue('text2Link');
  45.         $this->setValue('text2LinkTarget''_self');
  46.         $this->setValue('text2Statemanager', ['d-block d-sm-none''d-sm-block d-md-none''d-md-block d-lg-none''d-lg-block d-xl-none''d-xl-block']);
  47.         $this->setValue('icon3''check');
  48.         $this->setValue('text3''Lorem ipsum dolor sit amet');
  49.         $this->setValue('text3Slide');
  50.         $this->setValue('text3Link');
  51.         $this->setValue('text3LinkTarget''_self');
  52.         $this->setValue('text3Statemanager', ['d-block d-sm-none''d-sm-block d-md-none''d-md-block d-lg-none''d-lg-block d-xl-none''d-xl-block']);
  53.         $this->setValue('icon4''check');
  54.         $this->setValue('text4''Lorem ipsum dolor sit amet');
  55.         $this->setValue('text4Slide');
  56.         $this->setValue('text4Link');
  57.         $this->setValue('text4LinkTarget''_self');
  58.         $this->setValue('text4Statemanager', ['d-block d-sm-none''d-sm-block d-md-none''d-md-block d-lg-none''d-lg-block d-xl-none''d-xl-block']);
  59.         $this->setValue('iconFont''zenit-features-icon-feather-');
  60.         $this->setValue('backgroundColor''#242734');
  61.         $this->setValue('columnBackgroundColor''#34384b');
  62.         $this->setValue('textColor''#F2D2AA');
  63.         $this->setValue('textColorHover''#FFFFFF');
  64.         $this->setValue('borderRadius'3);
  65.         $this->setValue('padding'10);
  66.         $this->setValue('fontSize'16);
  67.         $this->setValue('iconSize'24);
  68.         $this->setValue('customCSS'null);
  69.     }
  70.     /**
  71.      * @param string $configName
  72.      * @param null $default
  73.      */
  74.     public function setValue(string $configName$default null) : void
  75.     {
  76.         $systemConfigService $this->container->get(SystemConfigService::class);
  77.         $domain $this->getName() . '.config.';
  78.         if( $systemConfigService->get($domain $configName) === null )
  79.         {
  80.             $systemConfigService->set($domain $configName$default);
  81.         }
  82.     }
  83. }