public function Payment::setPaymentStatus in Payment 8.2
Sets a status.
Parameters
\Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface $payment_status:
Return value
\Drupal\payment\Entity\PaymentInterface
Overrides PaymentInterface::setPaymentStatus
File
- src/
Entity/ Payment.php, line 240
Class
- Payment
- Defines a payment entity.
Namespace
Drupal\payment\EntityCode
public function setPaymentStatus(PluginPaymentStatusInterface $payment_status) {
$previous_status = $this
->getPaymentStatus();
$payment_status
->setPayment($this);
// Prevent duplicate statuses.
if (!$this
->getPaymentStatus() || $this
->getPaymentStatus()
->getPluginId() != $payment_status
->getPluginId()) {
$this
->get('payment_statuses')
->appendItem($payment_status);
}
/** @var \Drupal\payment\EventDispatcherInterface $event_dispatcher */
$event_dispatcher = \Drupal::service('payment.event_dispatcher');
$event_dispatcher
->setPaymentStatus($this, $previous_status);
return $this;
}