/** * @param Quote $quote * * @return \Symfony\Component\HttpFoundation\RedirectResponse * * @throws InvalidTransitionException */ public function send(Quote $quote) { $finite = $this->stateMachine->get($quote, Graph::GRAPH); if ($quote->getStatus() !== Graph::STATUS_PENDING) { if (!$finite->can(Graph::TRANSITION_SEND)) { throw new InvalidTransitionException(Graph::TRANSITION_SEND); } $this->dispatcher->dispatch(QuoteEvents::QUOTE_PRE_SEND, new QuoteEvent($quote)); $this->applyTransition($quote, Graph::TRANSITION_SEND); $this->dispatcher->dispatch(QuoteEvents::QUOTE_POST_SEND, new QuoteEvent($quote)); } else { $this->mailer->sendQuote($quote); } return $quote; }
/** * @param QuoteEvent $event */ public function onQuoteSend(QuoteEvent $event) { $this->mailer->sendQuote($event->getQuote()); }
/** * @param InvoiceEvent $event */ public function onInvoiceAccepted(InvoiceEvent $event) { $this->mailer->sendInvoice($event->getInvoice()); }