diff --git a/src/Resources/app/storefront/src/main.js b/src/Resources/app/storefront/src/main.js index 41b14800b..4a9a0a3ff 100644 --- a/src/Resources/app/storefront/src/main.js +++ b/src/Resources/app/storefront/src/main.js @@ -6,8 +6,6 @@ import MollieRegistration from './register'; // also work, as long as its built in the Shopware version that uses it. if (window.mollie_javascript_use_shopware !== undefined && window.mollie_javascript_use_shopware === '1') { - const molliePlugins = new MollieRegistration(); - molliePlugins.register(); -} +} \ No newline at end of file diff --git a/src/Resources/app/storefront/src/mollie-payments/Plugin.js b/src/Resources/app/storefront/src/mollie-payments/Plugin.js new file mode 100644 index 000000000..aaa57af29 --- /dev/null +++ b/src/Resources/app/storefront/src/mollie-payments/Plugin.js @@ -0,0 +1,2 @@ +import ShopwarePlugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; +export default class Plugin extends ShopwarePlugin{} \ No newline at end of file diff --git a/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js b/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js index 211fe6f47..f9942cb00 100644 --- a/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js @@ -1,5 +1,5 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; +import Plugin from "../Plugin"; /** * This plugin manage the credit card mandate of the customer diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js index b4853b5cf..93c264ace 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js @@ -1,5 +1,5 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; +import Plugin from "../Plugin"; export default class MollieApplePayDirect extends Plugin { diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js index 3d819c3e4..a2856efa8 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js @@ -1,5 +1,5 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; +import Plugin from "../Plugin"; export default class MollieApplePayPaymentMethod extends Plugin { diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js index b08b04aed..eee0d5b46 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js @@ -1,4 +1,4 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; +import Plugin from "../Plugin"; export default class MollieBancomatPlugin extends Plugin { diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js index 6413a5df4..0903a86c0 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js @@ -1,5 +1,5 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; +import Plugin from "../Plugin"; /** * This plugin manage the credit card mandate of customer diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js index fc4085199..a684e203b 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js @@ -1,5 +1,5 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient' +import Plugin from "../Plugin"; export default class MollieIDealIssuer extends Plugin { diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js index 7aeadada5..610f1dd7c 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js @@ -1,5 +1,5 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient' +import Plugin from "../Plugin"; export default class MolliePosTerminalPlugin extends Plugin { diff --git a/src/Resources/app/storefront/webpack.config.js b/src/Resources/app/storefront/webpack.config.js index e2f5a76a7..d5c692a76 100644 --- a/src/Resources/app/storefront/webpack.config.js +++ b/src/Resources/app/storefront/webpack.config.js @@ -16,4 +16,4 @@ module.exports = { ), }, }, -} +} \ No newline at end of file diff --git a/src/Resources/config/services/subscriber.xml b/src/Resources/config/services/subscriber.xml index 7f635b9a6..5c400c9dc 100644 --- a/src/Resources/config/services/subscriber.xml +++ b/src/Resources/config/services/subscriber.xml @@ -43,7 +43,7 @@ - %kernel.shopware_version% + diff --git a/src/Subscriber/StorefrontBuildSubscriber.php b/src/Subscriber/StorefrontBuildSubscriber.php index f29d977e1..c21febd87 100644 --- a/src/Subscriber/StorefrontBuildSubscriber.php +++ b/src/Subscriber/StorefrontBuildSubscriber.php @@ -5,6 +5,7 @@ use Kiener\MolliePayments\Compatibility\VersionCompare; use Kiener\MolliePayments\Service\SettingsService; use Shopware\Storefront\Event\StorefrontRenderEvent; +use Shopware\Storefront\Theme\StorefrontPluginConfiguration\StorefrontPluginConfiguration; use Shopware\Storefront\Theme\StorefrontPluginRegistryInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -25,16 +26,16 @@ class StorefrontBuildSubscriber implements EventSubscriberInterface */ private $versionCompare; - /** * @param SettingsService $settingsService - * @param string $shopwareVersion + * @param StorefrontPluginRegistryInterface $pluginRegistry + * @param VersionCompare $versionCompare */ - public function __construct(SettingsService $settingsService, StorefrontPluginRegistryInterface $pluginRegistry, string $shopwareVersion) + public function __construct(SettingsService $settingsService, StorefrontPluginRegistryInterface $pluginRegistry, VersionCompare $versionCompare) { $this->settingsService = $settingsService; $this->pluginRegistry = $pluginRegistry; - $this->versionCompare = new VersionCompare($shopwareVersion); + $this->versionCompare = $versionCompare; } /** @@ -60,10 +61,20 @@ public function onStorefrontRender(StorefrontRenderEvent $event): void $event->setParameter('mollie_javascript_use_shopware', $useJsValue); $mollieJavascriptAlreadyExists = false; + if ($this->versionCompare->gte('6.6')) { - $molliePayments = $this->pluginRegistry->getConfigurations()->getByTechnicalName('MolliePayments'); - $mollieJavascriptAlreadyExists = $molliePayments && ($molliePayments->getScriptFiles()->count() > 0); + $plugin = $this->pluginRegistry->getConfigurations()->getByTechnicalName('MolliePayments'); + + if ($plugin instanceof StorefrontPluginConfiguration) { + $scriptFiles = $plugin->getScriptFiles(); + + if ($useJsValue === 0) { + $scriptFiles->remove(0); + } + $mollieJavascriptAlreadyExists = $scriptFiles->count() > 0; + } } + $event->setParameter('mollie_javascript_already_exists', $mollieJavascriptAlreadyExists); } }