Created
October 1, 2017 14:57
-
-
Save clrockwell/b055f9d0a4ec4509467b83ab4ff12e06 to your computer and use it in GitHub Desktop.
Example of creating a plugin instance with the default configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// using PayPal EC as example | |
/** @var PaymentGatewayManager $plugin */ | |
$plugin = \Drupal::service('plugin.manager.commerce_payment_gateway'); | |
// Get the id of config from `drupal debug:config | grep paypal` | |
/** @var Config $config */ | |
$config = \Drupal::service('config.factory') | |
->get('commerce_payment.commerce_payment_gateway.paypal_ec'); | |
/** @var ExpressCheckout $ppec */ | |
$instance = $plugin->createInstance('paypal_express_checkout', $config->get()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment