custom/plugins/bp-plugin-shopware6-api2-1.3.0/src/BetterPayment.php line 17

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace BetterPayment;
  3. use BetterPayment\Installer\PaymentMethodInstaller;
  4. use BetterPayment\Installer\CustomFieldInstaller;
  5. use BetterPayment\Installer\RuleInstaller;
  6. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  7. use Shopware\Core\Framework\Plugin;
  8. use Shopware\Core\Framework\Plugin\Context\ActivateContext;
  9. use Shopware\Core\Framework\Plugin\Context\DeactivateContext;
  10. use Shopware\Core\Framework\Plugin\Context\InstallContext;
  11. use Shopware\Core\Framework\Plugin\Context\UninstallContext;
  12. use Shopware\Core\Framework\Plugin\Context\UpdateContext;
  13. use Shopware\Core\Framework\Plugin\Util\PluginIdProvider;
  14. class BetterPayment extends Plugin
  15. {
  16.     public const PLUGIN_NAME 'BetterPayment';
  17.     public function install(InstallContext $installContext): void
  18.     {
  19.         $this->getPaymentMethodInstaller()->install($installContext);
  20.         $this->getCustomFieldInstaller()->install($installContext);
  21.         $this->getRuleInstaller()->install($installContext);
  22.     }
  23.     public function update(UpdateContext $updateContext): void
  24.     {
  25.         $this->getPaymentMethodInstaller()->update($updateContext);
  26.     }
  27.     public function uninstall(UninstallContext $uninstallContext): void
  28.     {
  29.         $this->getPaymentMethodInstaller()->uninstall($uninstallContext);
  30.     }
  31.     public function activate(ActivateContext $activateContext): void
  32.     {
  33.         $this->getPaymentMethodInstaller()->activate($activateContext);
  34.     }
  35.     public function deactivate(DeactivateContext $deactivateContext): void
  36.     {
  37.         $this->getPaymentMethodInstaller()->deactivate($deactivateContext);
  38.     }
  39.     public function getPaymentMethodInstaller(): PaymentMethodInstaller
  40.     {
  41.         /** @var PluginIdProvider $pluginIdProvider */
  42.         $pluginIdProvider $this->container->get(PluginIdProvider::class);
  43.         /** @var EntityRepositoryInterface $paymentMethodRepository */
  44.         $paymentMethodRepository $this->container->get('payment_method.repository');
  45.         return new PaymentMethodInstaller($pluginIdProvider$paymentMethodRepository);
  46.     }
  47.     private function getCustomFieldInstaller(): CustomFieldInstaller
  48.     {
  49.         /** @var EntityRepositoryInterface $customFieldSetRepository */
  50.         $customFieldSetRepository $this->container->get('custom_field_set.repository');
  51.         return new CustomFieldInstaller($customFieldSetRepository);
  52.     }
  53.     private function getRuleInstaller(): RuleInstaller
  54.     {
  55.         /** @var EntityRepositoryInterface $ruleRepository */
  56.         $ruleRepository $this->container->get('rule.repository');
  57.         return new RuleInstaller($ruleRepository);
  58.     }
  59. }