You are here

class PaymentExecuteAccess in Payment 8.2

Provides an event that is dispatched when access is checked for payment execution.

Hierarchy

Expanded class hierarchy of PaymentExecuteAccess

See also

\Drupal\payment\Event\PaymentEvents::PAYMENT_EXECUTE_ACCESS

4 files declare their use of PaymentExecuteAccess
EventDispatcherCollectionTest.php in tests/src/Unit/EventDispatcherCollectionTest.php
PaymentExecuteAccessTest.php in tests/src/Unit/Event/PaymentExecuteAccessTest.php
SymfonyEventDispatcher.php in src/SymfonyEventDispatcher.php
SymfonyEventDispatcherTest.php in tests/src/Unit/SymfonyEventDispatcherTest.php

File

src/Event/PaymentExecuteAccess.php, line 18

Namespace

Drupal\payment\Event
View source
class PaymentExecuteAccess extends Event {

  /**
   * The access check result.
   *
   * @var \Drupal\Core\Access\AccessResultInterface
   */
  protected $accessResult;

  /**
   * The account to check access for.
   *
   * @var \Drupal\payment\Entity\PaymentInterface
   */
  protected $account;

  /**
   * The payment.
   *
   * @var \Drupal\payment\Entity\PaymentInterface
   */
  protected $payment;

  /**
   * The payment method.
   *
   * @var \Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface
   */
  protected $paymentMethod;

  /**-
   * Constructs a new instance.
   *
   * @param \Drupal\payment\Entity\PaymentInterface $payment
   *   The payment for which the context will be resumed
   * @param \Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface $payment_method
   *
   * @param \Drupal\Core\Session\AccountInterface
   */
  public function __construct(PaymentInterface $payment, PaymentMethodInterface $payment_method, AccountInterface $account) {
    $this->accessResult = new AccessResultAllowed();
    $this->payment = $payment;
    $this->paymentMethod = $payment_method;
    $this->account = $account;
  }

  /**
   * Gets the payment for which execution access is checked.
   *
   * @return \Drupal\payment\Entity\PaymentInterface
   *   $payment->getPaymentMethod() contains the method currently configured,
   *   but NOT the method that $payment should be tested against, which is
   *   $payment_method.
   */
  public function getPayment() {
    return $this->payment;
  }

  /**
   * Gets the payment method that should execute the payment.
   *
   * @return \Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface
   */
  public function getPaymentMethod() {
    return $this->paymentMethod;
  }

  /**
   * Gets the account for which to check access.
   *
   * @return \Drupal\Core\Session\AccountInterface
   */
  public function getAccount() {
    return $this->account;
  }

  /**
   * Gets the access check result.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   */
  public function getAccessResult() {
    return $this->accessResult;
  }

  /**
   * Sets an access check result.
   *
   * @param \Drupal\Core\Access\AccessResultInterface
   *
   * @return $this
   */
  public function setAccessResult(AccessResultInterface $access_result) {
    $this->accessResult = $this->accessResult
      ->orIf($access_result);
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PaymentExecuteAccess::$accessResult protected property The access check result.
PaymentExecuteAccess::$account protected property The account to check access for.
PaymentExecuteAccess::$payment protected property The payment.
PaymentExecuteAccess::$paymentMethod protected property The payment method.
PaymentExecuteAccess::getAccessResult public function Gets the access check result.
PaymentExecuteAccess::getAccount public function Gets the account for which to check access.
PaymentExecuteAccess::getPayment public function Gets the payment for which execution access is checked.
PaymentExecuteAccess::getPaymentMethod public function Gets the payment method that should execute the payment.
PaymentExecuteAccess::setAccessResult public function Sets an access check result.
PaymentExecuteAccess::__construct public function