Beispiel #1
0
 /**
  * @param Quote  $quote
  * @param string $transition
  *
  * @return bool
  *
  * @throws InvalidTransitionException
  */
 private function applyTransition(Quote $quote, $transition)
 {
     $stateMachine = $this->stateMachine->get($quote, Graph::GRAPH);
     if ($stateMachine->can($transition)) {
         $oldStatus = $quote->getStatus();
         $stateMachine->apply($transition);
         $this->entityManager->persist($quote);
         $this->entityManager->flush();
         $newStatus = $quote->getStatus();
         $parameters = ['quote' => $quote, 'old_status' => $oldStatus, 'new_status' => $newStatus, 'transition' => $transition];
         $notification = new QuoteStatusNotification($parameters);
         $this->notification->sendNotification('quote_status_update', $notification);
         return true;
     }
     throw new InvalidTransitionException($transition);
 }
Beispiel #2
0
 /**
  * @param Invoice $invoice
  * @param string  $transition
  *
  * @return bool
  *
  * @throws InvalidTransitionException
  */
 private function applyTransition(Invoice $invoice, $transition)
 {
     $stateMachine = $this->stateMachine->get($invoice, Graph::GRAPH);
     if ($stateMachine->can($transition)) {
         $oldStatus = $invoice->getStatus();
         $stateMachine->apply($transition);
         $newStatus = $invoice->getStatus();
         $parameters = ['invoice' => $invoice, 'old_status' => $oldStatus, 'new_status' => $newStatus, 'transition' => $transition];
         // Do not send status updates for new invoices
         if ($transition !== Graph::TRANSITION_NEW) {
             $notification = new InvoiceStatusNotification($parameters);
             $this->notification->sendNotification('invoice_status_update', $notification);
         }
         return true;
     }
     throw new InvalidTransitionException($transition);
 }
 /**
  * @param PaymentCompleteEvent $event
  */
 public function onPaymentCapture(PaymentCompleteEvent $event)
 {
     $notification = new PaymentReceivedNotification(array('payment' => $event->getPayment()));
     $this->notification->sendNotification('payment_made', $notification);
 }