<?php declare(strict_types=1);
/**
* @copyright 2020 Crehler Sp. z o. o.
* @link https://crehler.com/
* @support support@crehler.com
*
* @author Mateusz FlasiĆski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Crehler\AdvancedMenu;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\System\CustomField\CustomFieldTypes;
class CrehlerAdvancedMenu extends Plugin
{
const FIELD_COLUMN_COUNT = 'crehler_advanced_menu_column_count';
public function activate(ActivateContext $activateContext): void
{
$this->createCustomFields($activateContext->getContext());
parent::activate($activateContext);
}
public function update(UpdateContext $updateContext): void
{
$this->createCustomFields($updateContext->getContext());
parent::update($updateContext);
}
private function createCustomFields(Context $context): void
{
$customFieldSetRepository = $this->container->get('custom_field_set.repository');
$customFieldSetRepository->upsert([
[
'id' => 'd7bda3285a8241b3bf34e49aa19321c6',
'name' => 'crehler_advanced_menu',
'global' => false,
'config' => [
'label' => [
'de-DE' => 'Products Menu',
'en-GB' => 'Products Menu',
'pl-PL' => 'Menu Produkty'
],
],
'relations' => [[
'id' => '2e5952107f3c4a7fa103d40f2e8979aa',
'entityName' => 'category',
]],
'customFields' => [
[
'id' => '8b6d3ffeb8504cef955a80e425ed629e',
'name' => self::FIELD_COLUMN_COUNT,
'type' => CustomFieldTypes::INT,
'config' => [
'label' => [
'de-DE' => 'Columns',
'en-GB' => 'Columns',
'pl-PL' => 'Kolumny'
],
],
]
],
],
], $context);
}
}