<?php declare(strict_types=1);
namespace Cogi\CmsLayouts;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Cogi\CmsLayouts\Core\CustomFieldWizard;
class CogiCmsLayouts extends Plugin
{
/**
* @param InstallContext $installContext
*/
public function install(InstallContext $installContext): void
{
parent::install($installContext);
$this->installCustomFields($installContext->getContext());
}
/**
* @param UpdateContext $installContext
*/
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_cms_layouts', $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_cms_layouts', $this->container, $context);
$customFieldWizard
->addFieldSet(
'cms_block',
[
'de-DE' => 'CMS-Layouts Sondereinstellungen',
'en-GB' => 'CMS-Layouts additional settings'
],
['cms_block']
)
->addField(
'cms_block', 'grid_gap', 'text',
[
'de-DE' => 'Abstand zwischen Kacheln',
'en-GB' => 'Grid gap'
]
)
->install();
} catch (\Exception $e) {
// Something went wrong
}
}
}