<?php declare(strict_types=1);
namespace zenit\PlatformShippingBar;
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 zenitPlatformShippingBar 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('tooltips', true);
$this->setValue('paymentExtension', 'noextend');
$this->setValue('paymentExtensionDivider', ' | ');
$this->setValue('paymentExtensionPaymentText', 'Zahlen Sie mit:');
$this->setValue('paymentExtensionShippingText', 'Wir versenden mit:');
$this->setValue('topBar', 'prepend');
$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']);
$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']);
$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']);
$this->setValue('footerBar', 'none');
$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']);
$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']);
$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']);
$this->setValue('icons', []);
$this->setValue('customShipping', null);
$this->setValue('content1Icon', 'package-open');
$this->setValue('content1Text', 'Kostenloser Versand');
$this->setValue('content1Url', '/shipping');
$this->setValue('content1Show', true);
$this->setValue('content2Icon', 'headset');
$this->setValue('content2Text', '0180 000 000');
$this->setValue('content2Url', 'tel:+49180000000');
$this->setValue('content2Show', true);
$this->setValue('content3Icon', 'envelope');
$this->setValue('content3Text', 'test@example.de');
$this->setValue('content3Url', 'mailto:test@example.de');
$this->setValue('content3Show', true);
$this->setValue('iconStyle', 'icon-default');
$this->setValue('backgroundColor', '#242734');
$this->setValue('textColor', '#F2D2AA');
$this->setValue('textHoverColor', '#6a7f95');
$this->setValue('padding', 5);
$this->setValue('fontSize', 14);
$this->setValue('iconHoverAnimation', true);
$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);
}
}
}