custom/plugins/CogiThemeTulip/src/CogiThemeTulip.php line 14

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Cogi\Theme\Tulip;
  3. use Shopware\Core\Framework\Context;
  4. use Shopware\Core\Framework\Plugin;
  5. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  6. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  7. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  8. use Shopware\Storefront\Framework\ThemeInterface;
  9. use Cogi\Theme\Tulip\Core\CustomFieldWizard;
  10. class CogiThemeTulip extends Plugin implements ThemeInterface
  11. {
  12.     public function getThemeConfigPath(): string
  13.     {
  14.         return 'theme.json';
  15.     }
  16.     /**
  17.      * @param InstallContext $installContext
  18.      */
  19.     public function install(InstallContext $installContext): void
  20.     {
  21.         parent::install($installContext);
  22.         $this->installCustomFields($installContext->getContext());
  23.     }
  24.     /**
  25.      * @param UpdateContext $updateContext
  26.      */
  27.     public function update(UpdateContext $updateContext): void
  28.     {
  29.         parent::update($updateContext);
  30.         $this->installCustomFields($updateContext->getContext());
  31.     }
  32.     /**
  33.      * @param UninstallContext $uninstallContext
  34.      */
  35.     public function uninstall(UninstallContext $uninstallContext): void
  36.     {
  37.         try {
  38.             $customFieldWizard = new CustomFieldWizard('cogi_theme_tulip'$this->container$uninstallContext->getContext());
  39.             $customFieldWizard->uninstall();
  40.         } catch (\Exception $e) {
  41.             // Something went wrong
  42.         }
  43.         parent::uninstall($uninstallContext);
  44.     }
  45.     /**
  46.      * @param $context Context
  47.      */
  48.     protected function installCustomFields(Context $context)
  49.     {
  50.         try {
  51.             $customFieldWizard = new CustomFieldWizard('cogi_theme_tulip'$this->container$context);
  52.             $customFieldWizard
  53.                 ->addFieldSet(
  54.                     'category',
  55.                     [
  56.                         'de-DE' => 'Tulip Theme Kategorie-Einstellungen',
  57.                         'en-GB' => 'Tulip Theme Category Settings'
  58.                     ],
  59.                     ['category']
  60.                 )
  61.                 ->addField(
  62.                     'category''use_megamenu''checkbox',
  63.                     [
  64.                         'de-DE' => 'Megamenu nutzen',
  65.                         'en-GB' => 'Use mega menu'
  66.                     ]
  67.                 )
  68.                 ->addFieldSet(
  69.                     'product',
  70.                     [
  71.                         'de-DE' => 'Tulip Theme: Weitere Produktinfos',
  72.                         'en-GB' => 'Tulip Theme: Additional product infos'
  73.                     ],
  74.                     ['product']
  75.                 )
  76.                 ->addField(
  77.                     'product''bullet_area''html',
  78.                     [
  79.                         'de-DE' => 'Kurzbeschreibung unter Warenkorb-Bereich',
  80.                         'en-GB' => 'Short description below "Add to Cart"-area'
  81.                     ], [], 'sw-text-editor''textEditor'
  82.                 )
  83.                 ->addField(
  84.                     'product''bullet_area_bullet_icon''select',
  85.                     [
  86.                         'de-DE' => 'Listenzeichen in Kurzbeschreibung',
  87.                         'en-GB' => 'List bullet icons in short description'
  88.                     ], [], 'sw-single-select''select',
  89.                     [
  90.                         [
  91.                             "label" => [
  92.                                 'de-DE' => 'Standardsymbol (siehe Plugin Konfiguration)',
  93.                                 'en-GB' => 'Default (see plugin configuration)'
  94.                             ],
  95.                             "value" => ""
  96.                         ],
  97.                         [
  98.                             "label" => [
  99.                                 'de-DE' => 'CSS-Standard',
  100.                                 'en-GB' => 'CSS standard'
  101.                             ],
  102.                             "value" => "default"
  103.                         ],
  104.                         [
  105.                             "label" => [
  106.                                 'de-DE' => 'Check-Icon',
  107.                                 'en-GB' => 'Check-Icon'
  108.                             ],
  109.                             "value" => "check"
  110.                         ],
  111.                         [
  112.                             "label" => [
  113.                                 'de-DE' => 'Pfeil-Icon',
  114.                                 'en-GB' => 'Arrow-Icon'
  115.                             ],
  116.                             "value" => "arrow"
  117.                         ],
  118.                     ]
  119.                 )
  120.                 ->install();
  121.         } catch (\Exception $e) {
  122.             // Something went wrong
  123.         }
  124.     }
  125. }