custom/plugins/digi1Moretabsforproductdetailpage/src/digi1Moretabsforproductdetailpage.php line 16

Open in your IDE?
  1. <?php declare(strict_types=1);
  2.     namespace digi1\digi1Moretabsforproductdetailpage;
  3.     use Shopware\Core\Framework\Plugin;
  4.     use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  5.     use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  6.     use Shopware\Core\Framework\Plugin\Context\InstallContext;
  7.     use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  8.     use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  9.     use Shopware\Core\System\CustomField\CustomFieldTypes;
  10.     use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  11.     use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
  12.     class digi1Moretabsforproductdetailpage extends Plugin {
  13.         public function install(InstallContext $installContext): void {
  14.             $customFieldSetRepository $this->container->get('custom_field_set.repository');
  15.             $criteria = new Criteria();
  16.             $criteria->addFilter(new EqualsFilter('name''digi1_owntabs'));
  17.             $result $customFieldSetRepository->searchIds($criteria$installContext->getContext());
  18.             if ($result->getTotal() == 0) {
  19.                 $customFieldSetRepository->create([[
  20.                     'name' => 'digi1_owntabs',
  21.                     'config' => [
  22.                         'label' => [
  23.                             'de-DE' => 'Tabs',
  24.                             'en-GB' => 'tabs'
  25.                         ],
  26.                         'translated' => true
  27.                     ],
  28.                     'customFields' => [
  29.                         [
  30.                             'name' => 'digi1_owntabs_tab1headline',
  31.                             'type' => CustomFieldTypes::TEXT,
  32.                             'config' => [
  33.                                 'label' => [
  34.                                     'de-DE' => 'Tab 1 Überschrift',
  35.                                     'en-GB' => 'tab 1 headline'
  36.                                 ],
  37.                                 'componentName' => 'sw-field',
  38.                                 'customFieldType' => 'text',
  39.                                 'customFieldPosition' => 1,
  40.                                 'type' => 'text'
  41.                             ]
  42.                         ],
  43.                         [
  44.                             'name' => 'digi1_owntabs_tab1content',
  45.                             'type' => CustomFieldTypes::HTML,
  46.                             'config' => [
  47.                                 'label' => [
  48.                                     'de-DE' => 'Tab 1 Inhalt',
  49.                                     'en-GB' => 'tab 1 content'
  50.                                 ],
  51.                                 'componentName' => 'sw-text-editor',
  52.                                 'customFieldType' => 'textEditor',
  53.                                 'customFieldPosition' => 2
  54.                             ]
  55.                         ],
  56.                         [
  57.                             'name' => 'digi1_owntabs_tab2headline',
  58.                             'type' => CustomFieldTypes::TEXT,
  59.                             'config' => [
  60.                                 'label' => [
  61.                                     'de-DE' => 'Tab 2 Überschrift',
  62.                                     'en-GB' => 'tab 2 headline'
  63.                                 ],
  64.                                 'componentName' => 'sw-field',
  65.                                 'customFieldType' => 'text',
  66.                                 'customFieldPosition' => 3,
  67.                                 'type' => 'text'
  68.                             ]
  69.                         ],
  70.                         [
  71.                             'name' => 'digi1_owntabs_tab2content',
  72.                             'type' => CustomFieldTypes::HTML,
  73.                             'config' => [
  74.                                 'label' => [
  75.                                     'de-DE' => 'Tab 2 Inhalt',
  76.                                     'en-GB' => 'tab 2 content'
  77.                                 ],
  78.                                 'componentName' => 'sw-text-editor',
  79.                                 'customFieldType' => 'textEditor',
  80.                                 'customFieldPosition' => 4
  81.                             ]
  82.                         ],
  83.                         [
  84.                             'name' => 'digi1_owntabs_tab3headline',
  85.                             'type' => CustomFieldTypes::TEXT,
  86.                             'config' => [
  87.                                 'label' => [
  88.                                     'de-DE' => 'Tab 3 Überschrift',
  89.                                     'en-GB' => 'tab 3 headline'
  90.                                 ],
  91.                                 'componentName' => 'sw-field',
  92.                                 'customFieldType' => 'text',
  93.                                 'customFieldPosition' => 5,
  94.                                 'type' => 'text'
  95.                             ]
  96.                         ],
  97.                         [
  98.                             'name' => 'digi1_owntabs_tab3content',
  99.                             'type' => CustomFieldTypes::HTML,
  100.                             'config' => [
  101.                                 'label' => [
  102.                                     'de-DE' => 'Tab 3 Inhalt',
  103.                                     'en-GB' => 'tab 3 content'
  104.                                 ],
  105.                                 'componentName' => 'sw-text-editor',
  106.                                 'customFieldType' => 'textEditor',
  107.                                 'customFieldPosition' => 6
  108.                             ]
  109.                         ],
  110.                         [
  111.                             'name' => 'digi1_owntabs_tab4headline',
  112.                             'type' => CustomFieldTypes::TEXT,
  113.                             'config' => [
  114.                                 'label' => [
  115.                                     'de-DE' => 'Tab 4 Überschrift',
  116.                                     'en-GB' => 'tab 4 headline'
  117.                                 ],
  118.                                 'componentName' => 'sw-field',
  119.                                 'customFieldType' => 'text',
  120.                                 'customFieldPosition' => 7,
  121.                                 'type' => 'text'
  122.                             ]
  123.                         ],
  124.                         [
  125.                             'name' => 'digi1_owntabs_tab4content',
  126.                             'type' => CustomFieldTypes::HTML,
  127.                             'config' => [
  128.                                 'label' => [
  129.                                     'de-DE' => 'Tab 4 Inhalt',
  130.                                     'en-GB' => 'tab 4 content'
  131.                                 ],
  132.                                 'componentName' => 'sw-text-editor',
  133.                                 'customFieldType' => 'textEditor',
  134.                                 'customFieldPosition' => 8
  135.                             ]
  136.                         ],
  137.                         [
  138.                             'name' => 'digi1_owntabs_tab5headline',
  139.                             'type' => CustomFieldTypes::TEXT,
  140.                             'config' => [
  141.                                 'label' => [
  142.                                     'de-DE' => 'Tab 5 Überschrift',
  143.                                     'en-GB' => 'tab 5 headline'
  144.                                 ],
  145.                                 'componentName' => 'sw-field',
  146.                                 'customFieldType' => 'text',
  147.                                 'customFieldPosition' => 9,
  148.                                 'type' => 'text'
  149.                             ]
  150.                         ],
  151.                         [
  152.                             'name' => 'digi1_owntabs_tab5content',
  153.                             'type' => CustomFieldTypes::HTML,
  154.                             'config' => [
  155.                                 'label' => [
  156.                                     'de-DE' => 'Tab 5 Inhalt',
  157.                                     'en-GB' => 'tab 5 content'
  158.                                 ],
  159.                                 'componentName' => 'sw-text-editor',
  160.                                 'customFieldType' => 'textEditor',
  161.                                 'customFieldPosition' => 9
  162.                             ]
  163.                         ]
  164.                     ],
  165.                     'relations' => [
  166.                         ['entityName' => 'product']
  167.                     ]
  168.                 ]], $installContext->getContext());
  169.             }
  170.             parent::install($installContext);
  171.         }
  172.         public function postInstall(InstallContext $installContext): void {
  173.             parent::postInstall($installContext);
  174.         }
  175.         public function update(UpdateContext $updateContext): void {
  176.         }
  177.         public function postUpdate(UpdateContext $updateContext): void {
  178.         }
  179.         public function activate(ActivateContext $activateContext): void {
  180.             parent::activate($activateContext);
  181.         }
  182.         public function deactivate(DeactivateContext $deactivateContext): void {
  183.             parent::deactivate($deactivateContext);
  184.         }
  185.         public function uninstall(UninstallContext $uninstallContext): void {
  186.             $customFieldSetRepository $this->container->get('custom_field_set.repository');
  187.             $criteria = new Criteria();
  188.             $criteria->addFilter(new EqualsFilter('name''digi1_owntabs'));
  189.             $result $customFieldSetRepository->searchIds($criteria$uninstallContext->getContext());
  190.             if ($result->getTotal() > && !$uninstallContext->keepUserData()) {
  191.                 $data $result->getDataOfId($result->firstId());
  192.                 $customFieldSetRepository->delete([$data], $uninstallContext->getContext());
  193.             }
  194.             parent::uninstall($uninstallContext);
  195.         }
  196.     }