<?php declare(strict_types=1);
namespace zenit\PlatformFeaturesBar;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter;
use Shopware\Core\System\SystemConfig\SystemConfigService;
class zenitPlatformFeaturesBar extends Plugin
{
public function install(InstallContext $installContext): void
{
$this->addDefaultConfiguration();
parent::install($installContext);
}
public function uninstall(UninstallContext $uninstallContext): void
{
if ($uninstallContext->keepUserData()) {
parent::uninstall($uninstallContext);
return;
}
parent::uninstall($uninstallContext);
}
private function addDefaultConfiguration(): void
{
$this->setValue('active', true);
$this->setValue('allowedControllers', []);
$this->setValue('columnCount', '4');
$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']);
$this->setValue('positionTop', 'headerTop');
$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']);
$this->setValue('positionBottom', 'false'); // string!
$this->setValue('icon1', 'check');
$this->setValue('text1', 'Lorem ipsum dolor sit amet');
$this->setValue('text1Slide');
$this->setValue('text1Link');
$this->setValue('text1LinkTarget', '_self');
$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']);
$this->setValue('icon2', 'check');
$this->setValue('text2', 'Lorem ipsum dolor sit amet');
$this->setValue('text2Slide');
$this->setValue('text2Link');
$this->setValue('text2LinkTarget', '_self');
$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']);
$this->setValue('icon3', 'check');
$this->setValue('text3', 'Lorem ipsum dolor sit amet');
$this->setValue('text3Slide');
$this->setValue('text3Link');
$this->setValue('text3LinkTarget', '_self');
$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']);
$this->setValue('icon4', 'check');
$this->setValue('text4', 'Lorem ipsum dolor sit amet');
$this->setValue('text4Slide');
$this->setValue('text4Link');
$this->setValue('text4LinkTarget', '_self');
$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']);
$this->setValue('iconFont', 'zenit-features-icon-feather-');
$this->setValue('backgroundColor', '#242734');
$this->setValue('columnBackgroundColor', '#34384b');
$this->setValue('textColor', '#F2D2AA');
$this->setValue('textColorHover', '#FFFFFF');
$this->setValue('borderRadius', 3);
$this->setValue('padding', 10);
$this->setValue('fontSize', 16);
$this->setValue('iconSize', 24);
$this->setValue('customCSS', null);
}
/**
* @param string $configName
* @param null $default
*/
public function setValue(string $configName, $default = null) : void
{
$systemConfigService = $this->container->get(SystemConfigService::class);
$domain = $this->getName() . '.config.';
if( $systemConfigService->get($domain . $configName) === null )
{
$systemConfigService->set($domain . $configName, $default);
}
}
}