EventDispatcherCollection.php in Payment 8.2
File
src/EventDispatcherCollection.php
View source
<?php
namespace Drupal\payment;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Session\AccountInterface;
use Drupal\payment\Entity\PaymentInterface;
use Drupal\payment\Plugin\Payment\Method\PaymentMethodInterface;
use Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface;
class EventDispatcherCollection implements EventDispatcherInterface {
protected $eventDispatchers = [];
public function addEventDispatcher(EventDispatcherInterface $event_dispatcher) {
$this->eventDispatchers[] = $event_dispatcher;
return $this;
}
public function alterQueueLoadedPaymentIds($queue_id, $category_id, $owner_id, array $payment_ids) {
foreach ($this->eventDispatchers as $event_dispatcher) {
$payment_ids = $event_dispatcher
->alterQueueLoadedPaymentIds($queue_id, $category_id, $owner_id, $payment_ids);
}
return $payment_ids;
}
public function setPaymentStatus(PaymentInterface $payment, PaymentStatusInterface $previous_payment_status = NULL) {
foreach ($this->eventDispatchers as $event_dispatcher) {
$event_dispatcher
->setPaymentStatus($payment, $previous_payment_status);
}
}
public function preExecutePayment(PaymentInterface $payment) {
foreach ($this->eventDispatchers as $event_dispatcher) {
$event_dispatcher
->preExecutePayment($payment);
}
}
public function executePaymentAccess(PaymentInterface $payment, PaymentMethodInterface $payment_method, AccountInterface $account) {
$access = AccessResult::neutral();
foreach ($this->eventDispatchers as $event_dispatcher) {
$access = $access
->orIf($event_dispatcher
->executePaymentAccess($payment, $payment_method, $account));
}
return $access;
}
public function preCapturePayment(PaymentInterface $payment) {
foreach ($this->eventDispatchers as $event_dispatcher) {
$event_dispatcher
->preCapturePayment($payment);
}
}
public function preRefundPayment(PaymentInterface $payment) {
foreach ($this->eventDispatchers as $event_dispatcher) {
$event_dispatcher
->preRefundPayment($payment);
}
}
public function preResumeContext(PaymentInterface $payment) {
foreach ($this->eventDispatchers as $event_dispatcher) {
$event_dispatcher
->preResumeContext($payment);
}
}
}