- Issue created by @goz
- Merge request !181Issue #3544267: Should define LoggerChannelInstance type for $logger, not LoggerChannel → (Open) created by goz
Using D11 with commerce_stripe 2.1.0 and Monolog 3.0.5, when i want to create a payment gateway from interface, i have the error :
TypeError: Cannot assign Drupal\monolog\Logger\LoggerInterfacesAdapter to property Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement::$logger of type Drupal\Core\Logger\LoggerChannel in Drupal\commerce_stripe\Plugin\Commerce\PaymentGateway\StripePaymentElement::create() (line 178 of modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/StripePaymentElement.php).
In StripePaymentElement.php, $logger type should be LoggerChannelInterface, not LoggerChannel, so other modules like Monolog can handle logs.
Install monolog, install commerce_stripe and go to /admin/commerce/config/payment-gateways/add to add a stripe payment.
Replace
/**
* The logging channel.
*
* @var \Drupal\Core\Logger\LoggerChannel
*/
protected LoggerChannel $logger;
by
/**
* The logging channel.
*
* @var \Drupal\Core\Logger\LoggerChannelInterface
*/
protected LoggerChannelInterface $logger;
Active
2.0
Code