Commit 93d56ede authored by bojanz's avatar bojanz

Issue #2785591: Make payment gateway plugins aware of the parent config entity ID.

parent f9875d38
......@@ -54,7 +54,9 @@ class PaymentGatewayPluginCollection extends DefaultSingleLazyPluginCollection {
throw new PluginException("The payment gateway '{$this->entityId}' did not specify a plugin.");
}
parent::initializePlugin($instance_id);
$configuration = $this->configuration + ['_entity_id' => $this->entityId];
$plugin = $this->manager->createInstance($instance_id, $configuration);
$this->set($instance_id, $plugin);
}
}
......@@ -28,6 +28,13 @@ abstract class PaymentGatewayBase extends PluginBase implements PaymentGatewayIn
*/
protected $entityTypeManager;
/**
* The ID of the parent config entity.
*
* @var string
*/
protected $entityId;
/**
* The payment type used by the gateway.
*
......@@ -62,6 +69,9 @@ abstract class PaymentGatewayBase extends PluginBase implements PaymentGatewayIn
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
// The plugin most know the ID of its parent config entity.
$this->entityId = $configuration['_entity_id'];
unset($configuration['_entity_id']);
// Instantiate the types right away to ensure that their IDs are valid.
$this->paymentType = $payment_type_manager->createInstance($this->pluginDefinition['payment_type']);
foreach ($this->pluginDefinition['payment_method_types'] as $plugin_id) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment