vendor/crehler/advanced-menu/src/CrehlerAdvancedMenu.php line 21

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * @copyright 2020 Crehler Sp. z o. o.
  4.  * @link https://crehler.com/
  5.  * @support support@crehler.com
  6.  *
  7.  * @author Mateusz FlasiƄski
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Crehler\AdvancedMenu;
  13. use Shopware\Core\Framework\Context;
  14. use Shopware\Core\Framework\Plugin;
  15. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  16. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  17. use Shopware\Core\System\CustomField\CustomFieldTypes;
  18. class CrehlerAdvancedMenu extends Plugin
  19. {
  20.     const FIELD_COLUMN_COUNT 'crehler_advanced_menu_column_count';
  21.     public function activate(ActivateContext $activateContext): void
  22.     {
  23.         $this->createCustomFields($activateContext->getContext());
  24.         parent::activate($activateContext);
  25.     }
  26.     public function update(UpdateContext $updateContext): void
  27.     {
  28.         $this->createCustomFields($updateContext->getContext());
  29.         parent::update($updateContext);
  30.     }
  31.     private function createCustomFields(Context $context): void
  32.     {
  33.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  34.         $customFieldSetRepository->upsert([
  35.             [
  36.                 'id' => 'd7bda3285a8241b3bf34e49aa19321c6',
  37.                 'name' => 'crehler_advanced_menu',
  38.                 'global' => false,
  39.                 'config' => [
  40.                     'label' => [
  41.                         'de-DE' => 'Products Menu',
  42.                         'en-GB' => 'Products Menu',
  43.                         'pl-PL' => 'Menu Produkty'
  44.                     ],
  45.                 ],
  46.                 'relations' => [[
  47.                     'id' => '2e5952107f3c4a7fa103d40f2e8979aa',
  48.                     'entityName' => 'category',
  49.                 ]],
  50.                 'customFields' => [
  51.                     [
  52.                         'id' => '8b6d3ffeb8504cef955a80e425ed629e',
  53.                         'name' => self::FIELD_COLUMN_COUNT,
  54.                         'type' => CustomFieldTypes::INT,
  55.                         'config' => [
  56.                             'label' => [
  57.                                 'de-DE' => 'Columns',
  58.                                 'en-GB' => 'Columns',
  59.                                 'pl-PL' => 'Kolumny'
  60.                             ],
  61.                         ],
  62.                     ]
  63.                 ],
  64.             ],
  65.         ], $context);
  66.     }
  67. }