Skip to content

Commit

Permalink
Created version 1.5.12 of the Mollie plugin for Shopware 5
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinder committed Jun 9, 2020
1 parent c28c9e4 commit 7335fb6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 15 deletions.
59 changes: 51 additions & 8 deletions Components/Helpers/LogHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace MollieShopware\Components\Helpers;

use Psr\Container\ContainerInterface;
use Exception;
use Shopware\Components\DependencyInjection\Container;
use Shopware\Components\Logger;
use Symfony\Component\DependencyInjection\ContainerInterface;

class LogHelper
{
Expand Down Expand Up @@ -34,15 +36,20 @@ public function __construct(
/**
* Logs a message to the plugin logger.
*
* @param string $message
* @param string $logMethod
* @param null $exception
* @param string $message
* @param string $logMethod
* @param null $exception
* @param ContainerInterface|null $container
*
* @return bool
*/
public static function logMessage($message, $logMethod = self::LOG_ERROR, $exception = null)
public static function logMessage($message, $logMethod = self::LOG_ERROR, $exception = null, ContainerInterface $container = null)
{
// Set the container
static::$container = static::getContainer($container);

// Check if the log method exists
if (!method_exists(static::pluginLogger(), $logMethod)) {
if (!method_exists(static::pluginLogger(static::$container), $logMethod)) {
$logMethod = self::LOG_DEBUG;

// Throw a warning that the log level is unknown
Expand All @@ -52,7 +59,12 @@ public static function logMessage($message, $logMethod = self::LOG_ERROR, $excep
);
}

return static::pluginLogger()->$logMethod($message, [$exception]);
// Check if the plugin logger is available
if (static::pluginLogger() !== null) {
return static::pluginLogger()->$logMethod($message, [$exception]);
}

return false;
}

/**
Expand All @@ -64,7 +76,7 @@ public static function logMessage($message, $logMethod = self::LOG_ERROR, $excep
private static function pluginLogger(ContainerInterface $container = null)
{
// Set the container
static::$container = ($container === null ? static::$container : $container);
static::$container = static::getContainer($container);

// Get the plugin logger from the container
if (static::$pluginLogger === null && static::$container !== null) {
Expand All @@ -73,4 +85,35 @@ private static function pluginLogger(ContainerInterface $container = null)

return static::$pluginLogger;
}

/**
* Returns the container interface, or null if not available.
*
* @param ContainerInterface|null $container
*
* @return ContainerInterface|Container
*/
private static function getContainer(ContainerInterface $container = null)
{
// If the given container is null, but the global container is available, use it
if (
$container === null
&& static::$container !== null
) {
$container = static::$container;
}

// If the container is still null, try to use the singleton
if (
$container === null
) {
try {
$container = Shopware()->Container();
} catch (Exception $e) {
//
}
}

return $container;
}
}
2 changes: 1 addition & 1 deletion Components/MollieApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function create()

// add plugin name and version
$this->apiClient->addVersionString(
'MollieShopware/1.5.11'
'MollieShopware/1.5.12'
);
}
catch (\Exception $ex) {
Expand Down
2 changes: 1 addition & 1 deletion Resources/snippets/frontend/mollie/plugins.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ YourPaymentHasExpired="Your payment has expired. Please try again."
YourBasketCouldNotBeRestoredFromSession="Your basket could not be restored from session."
PleaseCheckYourBankStatementsAndContactSupport="Please check your bank statements and contact support if you feel this is in error."
RestoreYourOrder="Restore your order"
CreditCardHeadline="Vul uw creditcard gegevens in."
CreditCardHeadline="Geben Sie Ihre Kreditkarteninformationen ein."
CardHolderLabel="Name des Kreditkarteninhabers"
CardNumberLabel="Kreditkartennummer"
CardExpiryDateLabel="Ablaufdatum"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<input type="hidden" name="mollie_shopware_credit_card_token" id="cardToken" value="" />
<div class="block-group">
<div class="intro-text">
<span>{s namespace="frontend/mollie/plugins" name="CreditCardHeadLine"}Enter your card information{/s}</span>
{s namespace="frontend/mollie/plugins" name="CreditCardHeadline"}Enter your card information{/s}
</div>
</div>
<div class="block-group">
Expand Down
8 changes: 4 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<label lang="de">Mollie</label>
<label lang="nl">Mollie</label>

<version>1.5.11</version>
<version>1.5.12</version>
<copyright>(c) Mollie B.V.</copyright>
<author>Kiener E-commerce</author>
<link>https://www.kiener.nl</link>

<description lang="en">Plugin to allow iDeal payments using the Mollie API (1.5.11)</description>
<description lang="nl">Plugin die iDealbetalingen via de Mollie API doorgeeft (1.5.11)</description>
<description lang="de">Plugin um Zahlungen mit der Mollie API zu ermöglichen (1.5.11)</description>
<description lang="en">Plugin to allow iDeal payments using the Mollie API (1.5.12)</description>
<description lang="nl">Plugin die iDealbetalingen via de Mollie API doorgeeft (1.5.12)</description>
<description lang="de">Plugin um Zahlungen mit der Mollie API zu ermöglichen (1.5.12)</description>

<compatibility minVersion="5.3.0"/>
</plugin>

0 comments on commit 7335fb6

Please sign in to comment.