You are here

class PaymentExecutionPaymentMethodManager in Payment 8.2

Provides a payment method manager for executing a payment.

Hierarchy

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\Method
View 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);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
DiscoveryTrait::getDefinition public function 3
DiscoveryTrait::hasDefinition public function
PaymentAwarePluginManagerDecorator::$payment protected property The payment to inject into plugin instances.
PaymentAwarePluginManagerDecorator::createInstance public function Creates a pre-configured instance of a plugin. Overrides PluginManagerDecorator::createInstance
PaymentExecutionPaymentMethodManager::$account protected property The account for which to check execution access.
PaymentExecutionPaymentMethodManager::$decoratedPaymentMethodManager protected property The decorated payment method manager.
PaymentExecutionPaymentMethodManager::getOperationsProvider public function Gets the plugin's operations provider. Overrides PluginOperationsProviderProviderInterface::getOperationsProvider
PaymentExecutionPaymentMethodManager::processDecoratedDefinitions protected function Processes the definitions from the decorated discovery. Overrides PluginDiscoveryDecorator::processDecoratedDefinitions
PaymentExecutionPaymentMethodManager::__construct public function Creates a new instance. Overrides PaymentAwarePluginManagerDecorator::__construct
PluginDiscoveryDecorator::$decoratedDiscovery protected property The decorated discovery.
PluginDiscoveryDecorator::$pluginDefinitions protected property The processed plugin definitions.
PluginDiscoveryDecorator::$useCaches protected property Whether or not to use plugin caching.
PluginDiscoveryDecorator::clearCachedDefinitions public function Clears static and persistent plugin definition caches. Overrides CachedDiscoveryInterface::clearCachedDefinitions
PluginDiscoveryDecorator::getDefinitions public function Gets the definition of all plugins for this type. Overrides DiscoveryTrait::getDefinitions
PluginDiscoveryDecorator::useCaches public function Disable the use of caches. Overrides CachedDiscoveryInterface::useCaches
PluginManagerDecorator::$decoratedFactory protected property The decorated plugin factory.
PluginManagerDecorator::getInstance public function Gets a preconfigured instance of a plugin. Overrides MapperInterface::getInstance