custom/plugins/IwvOrdersCsvExporterV6/src/IwvOrdersCsvExporterV6.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Iwv\IwvOrdersCsvExporterV6;
  4. if (file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
  5.     require_once dirname(__DIR__) . '/vendor/autoload.php';
  6. }
  7. use Shopware\Core\Framework\Plugin;
  8. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  9. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  10. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  11. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  12. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  13. use Iwv\IwvOrdersCsvExporterV6\Services\Installation\IwvCustomFieldsInstallationService;
  14. class IwvOrdersCsvExporterV6 extends Plugin
  15. {
  16.     /**
  17.      * @param InstallContext $installContext
  18.      * @return void
  19.      */
  20.     public function install(InstallContext $installContext): void
  21.     {
  22.         $this->getIwvCustomFieldService()->installCustomFields($installContext->getContext(), $this->isActive());
  23.     }
  24.     /**
  25.      * @param UninstallContext $uninstallContext
  26.      * @return void
  27.      */
  28.     public function uninstall(UninstallContext $uninstallContext): void
  29.     {
  30.         if (!$uninstallContext->keepUserData()) {
  31.             $this->getIwvCustomFieldService()->uninstallCustomFields($uninstallContext->getContext());
  32.         }
  33.     }
  34.     /**
  35.      * @param UpdateContext $updateContext
  36.      * @return void
  37.      */
  38.     public function update(UpdateContext $updateContext): void
  39.     {
  40.         $this->getIwvCustomFieldService()->installCustomFields($updateContext->getContext());
  41.     }
  42.     /**
  43.      * @param ActivateContext $activateContext
  44.      * @return void
  45.      */
  46.     public function activate(ActivateContext $activateContext): void
  47.     {
  48.         $this->getIwvCustomFieldService()->changeCustomFieldsState(true$activateContext->getContext());
  49.     }
  50.     /**
  51.      * @param DeactivateContext $deactivateContext
  52.      * @return void
  53.      */
  54.     public function deactivate(DeactivateContext $deactivateContext): void
  55.     {
  56.         $this->getIwvCustomFieldService()->changeCustomFieldsState(false$deactivateContext->getContext());
  57.     }
  58.     /**
  59.      * @return IwvCustomFieldsInstallationService
  60.      */
  61.     protected function getIwvCustomFieldService(): IwvCustomFieldsInstallationService
  62.     {
  63.         $customFieldsSetRepository $this->container->get('custom_field_set.repository');
  64.         return (new IwvCustomFieldsInstallationService($customFieldsSetRepository));
  65.     }
  66. }