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

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Wolf\WolfPlatformConversionTopbar;
  3. use Shopware\Core\Framework\Plugin;
  4. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  5. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  6. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  7. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8. use Shopware\Core\System\SystemConfig\SystemConfigService;
  9. class WolfPlatformConversionTopbar extends Plugin
  10. {
  11.     public function install(InstallContext $context): void
  12.         {
  13.             $this->addDefaultConfiguration();
  14.         }
  15.     public function activate(ActivateContext $context): void
  16.         {
  17.         }
  18.     public function deactivate(DeactivateContext $context): void
  19.         {
  20.         }
  21.     public function uninstall(UninstallContext $context): void
  22.         {
  23.             parent::uninstall($context);
  24.             if ($context->keepUserData()) {
  25.                 return;
  26.             }
  27.         }
  28.     private function addDefaultConfiguration(): void
  29.         {
  30.             $this->setValue('active'true);
  31.         }
  32.             /**
  33.              * @param string $configName
  34.              * @param null $default
  35.              */
  36.             public function setValue(string $configName$default null) : void
  37.         {
  38.             $systemConfigService $this->container->get(SystemConfigService::class);
  39.             $domain $this->getName() . '.config.';
  40.             if( $systemConfigService->get($domain $configName) === null )
  41.             {
  42.                 $systemConfigService->set($domain $configName$default);
  43.             }
  44.         }
  45. }