custom/plugins/zenitPlatformShippingBar/src/zenitPlatformShippingBar.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace zenit\PlatformShippingBar;
  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 zenitPlatformShippingBar 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('tooltips'true);
  31.         $this->setValue('paymentExtension''noextend');
  32.         $this->setValue('paymentExtensionDivider'' | ');
  33.         $this->setValue('paymentExtensionPaymentText''Zahlen Sie mit:');
  34.         $this->setValue('paymentExtensionShippingText''Wir versenden mit:');
  35.         $this->setValue('topBar''prepend');
  36.         $this->setValue('statemanagerHeader', ['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']);
  37.         $this->setValue('statemanagerIconsHeader', ['d-flex d-sm-none''d-sm-flex d-md-none''d-md-flex d-lg-none''d-lg-flex d-xl-none''d-xl-flex']);
  38.         $this->setValue('statemanagerInformationsHeader', ['d-flex d-sm-none''d-sm-flex d-md-none''d-md-flex d-lg-none''d-lg-flex d-xl-none''d-xl-flex']);
  39.         $this->setValue('footerBar''none');
  40.         $this->setValue('statemanagerFooter', ['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('statemanagerIconsFooter', ['d-flex d-sm-none''d-sm-flex d-md-none''d-md-flex d-lg-none''d-lg-flex d-xl-none''d-xl-flex']);
  42.         $this->setValue('statemanagerInformationsFooter', ['d-flex d-sm-none''d-sm-flex d-md-none''d-md-flex d-lg-none''d-lg-flex d-xl-none''d-xl-flex']);
  43.         $this->setValue('icons', []);
  44.         $this->setValue('customShipping'null);
  45.         $this->setValue('content1Icon''package-open');
  46.         $this->setValue('content1Text''Kostenloser Versand');
  47.         $this->setValue('content1Url''/shipping');
  48.         $this->setValue('content1Show'true);
  49.         $this->setValue('content2Icon''headset');
  50.         $this->setValue('content2Text''0180 000 000');
  51.         $this->setValue('content2Url''tel:+49180000000');
  52.         $this->setValue('content2Show'true);
  53.         $this->setValue('content3Icon''envelope');
  54.         $this->setValue('content3Text''test@example.de');
  55.         $this->setValue('content3Url''mailto:test@example.de');
  56.         $this->setValue('content3Show'true);
  57.         $this->setValue('iconStyle''icon-default');
  58.         $this->setValue('backgroundColor''#242734');
  59.         $this->setValue('textColor''#F2D2AA');
  60.         $this->setValue('textHoverColor''#6a7f95');
  61.         $this->setValue('padding'5);
  62.         $this->setValue('fontSize'14);
  63.         $this->setValue('iconHoverAnimation'true);
  64.         $this->setValue('customCSS'null);
  65.     }
  66.     /**
  67.      * @param string $configName
  68.      * @param null $default
  69.      */
  70.     public function setValue(string $configName$default null) : void
  71.     {
  72.         $systemConfigService $this->container->get(SystemConfigService::class);
  73.         $domain $this->getName() . '.config.';
  74.         if( $systemConfigService->get($domain $configName) === null )
  75.         {
  76.             $systemConfigService->set($domain $configName$default);
  77.         }
  78.     }
  79. }