class PaymentExecutionPaymentMethodManager in Payment 8.2
Provides a payment method manager for executing a payment.
Hierarchy
- class \Drupal\plugin\PluginDiscovery\PluginDiscoveryDecorator implements CachedDiscoveryInterface, DiscoveryInterface uses DiscoveryTrait, DependencySerializationTrait
- class \Drupal\plugin\PluginManager\PluginManagerDecorator implements PluginManagerInterface
- class \Drupal\payment\Plugin\Payment\PaymentAwarePluginManagerDecorator
- class \Drupal\payment\Plugin\Payment\Method\PaymentExecutionPaymentMethodManager implements PaymentMethodManagerInterface
- class \Drupal\payment\Plugin\Payment\PaymentAwarePluginManagerDecorator
- class \Drupal\plugin\PluginManager\PluginManagerDecorator implements PluginManagerInterface
Expanded class hierarchy of PaymentExecutionPaymentMethodManager
See also
\Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface
3 files declare their use of PaymentExecutionPaymentMethodManager
- PaymentExecutionPaymentMethodManagerTest.php in tests/
src/ Unit/ Plugin/ Payment/ Method/ PaymentExecutionPaymentMethodManagerTest.php - PaymentForm.php in modules/
payment_form/ src/ Entity/ Payment/ PaymentForm.php - PaymentReferenceBase.php in src/
Element/ PaymentReferenceBase.php
File
- src/
Plugin/ Payment/ Method/ PaymentExecutionPaymentMethodManager.php, line 20
Namespace
Drupal\payment\Plugin\Payment\MethodView source
class PaymentExecutionPaymentMethodManager extends PaymentAwarePluginManagerDecorator implements PaymentMethodManagerInterface {
/**
* The account for which to check execution access.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* The decorated payment method manager.
*
* @var \Drupal\payment\Plugin\Payment\Method\PaymentMethodManagerInterface
*/
protected $decoratedPaymentMethodManager;
/**
* Creates a new instance.
*
* @param \Drupal\payment\Entity\PaymentInterface
* The payment to check execution access for.
* @param \Drupal\Core\Session\AccountInterface $account
* The account to check payment execution access for.
* @param \Drupal\payment\Plugin\Payment\Method\PaymentMethodManagerInterface $payment_method_manager
* The payment method manager.
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface|null $discovery
* A plugin discovery to use instead of the decorated plugin manager, or
* NULL to use the decorated plugin manager.
*/
public function __construct(PaymentInterface $payment, AccountInterface $account, PaymentMethodManagerInterface $payment_method_manager, DiscoveryInterface $discovery = NULL) {
parent::__construct($payment, $payment_method_manager, $discovery);
$this->account = $account;
$this->decoratedPaymentMethodManager = $payment_method_manager;
}
/**
* {@inheritdoc}
*/
protected function processDecoratedDefinitions(array $decorated_definitions) {
$processed_definitions = [];
foreach ($decorated_definitions as $plugin_id => $decorated_definition) {
/** @var \Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface $payment_method */
$payment_method = $this
->createInstance($plugin_id);
if ($payment_method
->executePaymentAccess($this->account)
->isAllowed()) {
$processed_definitions[$plugin_id] = $decorated_definition;
}
}
return $processed_definitions;
}
/**
* {@inheritdoc}
*/
public function getOperationsProvider($plugin_id) {
if ($this
->hasDefinition($plugin_id)) {
return $this->decoratedPaymentMethodManager
->getOperationsProvider($plugin_id);
}
else {
throw new PluginNotFoundException($plugin_id);
}
}
}