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

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace ChespackTwoTheme;
  3. use ChespackTwoTheme\Util\Lifecycle\Install;
  4. use ChespackTwoTheme\Util\Lifecycle\Update;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  6. use Shopware\Core\Framework\Plugin;
  7. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  8. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  9. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  10. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  11. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  12. use Shopware\Storefront\Framework\ThemeInterface;
  13. class ChespackTwoTheme extends Plugin implements ThemeInterface
  14. {
  15.     // Define custom field sets names
  16.     public const THEME_CUSTOM_FIELD_SET_CATEGORY_CTA_1 'custom_category_cta_1';
  17.     public const THEME_CUSTOM_FIELD_SET_CATEGORY_CTA_2 'custom_category_cta_2';
  18.     // Define custom fields names
  19.     // Category CTA custom fields
  20.     // 1st CTA-teaser
  21.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_ACTIVE_1 'chespack_category_cta_active_1';
  22.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_TITLE_1 'chespack_category_cta_title_1';
  23.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_TEXT_1 'chespack_category_cta_text_1';
  24.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_LINK_1 'chespack_category_cta_link_1';
  25.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_LINK_NEW_WINDOW_1 'chespack_category_cta_link_new_window_1';
  26.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_IMAGE_1 'chespack_category_cta_image_1';
  27.     // 2nd CTA-teaser
  28.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_ACTIVE_2 'chespack_category_cta_active_2';
  29.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_TITLE_2 'chespack_category_cta_title_2';
  30.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_TEXT_2 'chespack_category_cta_text_2';
  31.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_LINK_2 'chespack_category_cta_link_2';
  32.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_LINK_NEW_WINDOW_2 'chespack_category_cta_link_new_window_2';
  33.     public const THEME_CUSTOM_FIELD_CATEGORY_CTA_IMAGE_2 'chespack_category_cta_image_2';
  34.     /**
  35.      * Theme configuration
  36.      * @return string
  37.      */
  38.     public function getThemeConfigPath(): string
  39.     {
  40.         return 'theme.json';
  41.     }
  42.     /**
  43.      * @param InstallContext $context
  44.      */
  45.     public function install(InstallContext $context): void
  46.     {
  47.     }
  48.     /**
  49.      * @param UninstallContext $context
  50.      */
  51.     public function uninstall(UninstallContext $context): void
  52.     {
  53.     }
  54.     /**
  55.      * @param ActivateContext $context
  56.      */
  57.     public function activate(ActivateContext $context): void
  58.     {
  59.     }
  60.     /**
  61.      * @param DeactivateContext $context
  62.      */
  63.     public function deactivate(DeactivateContext $context): void
  64.     {
  65.     }
  66.     /**
  67.      * @param UpdateContext $updateContext
  68.      */
  69.     public function update(UpdateContext $updateContext): void
  70.     {
  71.         /** @var EntityRepositoryInterface $customFieldSetRepository */
  72.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  73.         /** @var EntityRepositoryInterface $customFieldRepository */
  74.         $customFieldRepository $this->container->get('custom_field.repository');
  75.         (new Update($customFieldSetRepository$customFieldRepository))->update($updateContext);
  76.         parent::update($updateContext);
  77.     }
  78. }