<?php declare(strict_types=1);
namespace Cogi\Theme\Tulip;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Storefront\Framework\ThemeInterface;
use Cogi\Theme\Tulip\Core\CustomFieldWizard;
class CogiThemeTulip extends Plugin implements ThemeInterface
{
public function getThemeConfigPath(): string
{
return 'theme.json';
}
/**
* @param InstallContext $installContext
*/
public function install(InstallContext $installContext): void
{
parent::install($installContext);
$this->installCustomFields($installContext->getContext());
}
/**
* @param UpdateContext $updateContext
*/
public function update(UpdateContext $updateContext): void
{
parent::update($updateContext);
$this->installCustomFields($updateContext->getContext());
}
/**
* @param UninstallContext $uninstallContext
*/
public function uninstall(UninstallContext $uninstallContext): void
{
try {
$customFieldWizard = new CustomFieldWizard('cogi_theme_tulip', $this->container, $uninstallContext->getContext());
$customFieldWizard->uninstall();
} catch (\Exception $e) {
// Something went wrong
}
parent::uninstall($uninstallContext);
}
/**
* @param $context Context
*/
protected function installCustomFields(Context $context)
{
try {
$customFieldWizard = new CustomFieldWizard('cogi_theme_tulip', $this->container, $context);
$customFieldWizard
->addFieldSet(
'category',
[
'de-DE' => 'Tulip Theme Kategorie-Einstellungen',
'en-GB' => 'Tulip Theme Category Settings'
],
['category']
)
->addField(
'category', 'use_megamenu', 'checkbox',
[
'de-DE' => 'Megamenu nutzen',
'en-GB' => 'Use mega menu'
]
)
->addFieldSet(
'product',
[
'de-DE' => 'Tulip Theme: Weitere Produktinfos',
'en-GB' => 'Tulip Theme: Additional product infos'
],
['product']
)
->addField(
'product', 'bullet_area', 'html',
[
'de-DE' => 'Kurzbeschreibung unter Warenkorb-Bereich',
'en-GB' => 'Short description below "Add to Cart"-area'
], [], 'sw-text-editor', 'textEditor'
)
->addField(
'product', 'bullet_area_bullet_icon', 'select',
[
'de-DE' => 'Listenzeichen in Kurzbeschreibung',
'en-GB' => 'List bullet icons in short description'
], [], 'sw-single-select', 'select',
[
[
"label" => [
'de-DE' => 'Standardsymbol (siehe Plugin Konfiguration)',
'en-GB' => 'Default (see plugin configuration)'
],
"value" => ""
],
[
"label" => [
'de-DE' => 'CSS-Standard',
'en-GB' => 'CSS standard'
],
"value" => "default"
],
[
"label" => [
'de-DE' => 'Check-Icon',
'en-GB' => 'Check-Icon'
],
"value" => "check"
],
[
"label" => [
'de-DE' => 'Pfeil-Icon',
'en-GB' => 'Arrow-Icon'
],
"value" => "arrow"
],
]
)
->install();
} catch (\Exception $e) {
// Something went wrong
}
}
}