Skip to content

Commit

Permalink
NTR: fix loading of script files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalij Mik committed May 22, 2024
1 parent f6f9a31 commit c9f025b
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/Resources/app/storefront/src/mollie-payments/Plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export default class Plugin extends window.PluginBaseClass{}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import HttpClient from '../services/HttpClient';
import Plugin from "../Plugin";

/**
* This plugin manage the credit card mandate of the customer
*/
export default class MollieCreditCardMandate extends window.PluginBaseClass {
export default class MollieCreditCardMandate extends Plugin {
static options = {
newCardMandateOption: null,
mollieCreditCardFormClass: '.mollie-components-credit-card',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import HttpClient from '../services/HttpClient';
import Plugin from "../Plugin";

export default class MollieApplePayDirect extends window.PluginBaseClass {
export default class MollieApplePayDirect extends Plugin {

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import HttpClient from '../services/HttpClient';
import Plugin from "../Plugin";

export default class MollieApplePayPaymentMethod extends window.PluginBaseClass {
export default class MollieApplePayPaymentMethod extends Plugin {

/**
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default class MollieBancomatPlugin extends window.PluginBaseClass {
import Plugin from "../Plugin";

export default class MollieBancomatPlugin extends Plugin {

init() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import HttpClient from '../services/HttpClient';
import Plugin from "../Plugin";

/**
* This plugin manage the credit card mandate of customer
*/
export default class MollieCreditCardMandateManage extends window.PluginBaseClass {
export default class MollieCreditCardMandateManage extends Plugin {
static options = {
shopUrl: null,
customerId: null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import HttpClient from '../services/HttpClient'
import Plugin from "../Plugin";


export default class MollieIDealIssuer extends window.PluginBaseClass {
export default class MollieIDealIssuer extends Plugin {

_shopUrl = '';
_customerId = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import HttpClient from '../services/HttpClient'
import Plugin from "../Plugin";


export default class MolliePosTerminalPlugin extends window.PluginBaseClass {
export default class MolliePosTerminalPlugin extends Plugin {

_shopUrl = '';
_customerId = '';
Expand Down
17 changes: 14 additions & 3 deletions src/Subscriber/StorefrontBuildSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -60,11 +61,21 @@ 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);
$event->setParameter('mollie_javascript_use_shopware', true);
$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);
$event->setParameter('mollie_javascript_already_exists', false);
}
}

0 comments on commit c9f025b

Please sign in to comment.