public function __construct($name, Payment $payment, FinancialTransaction $transaction) { parent::__construct($name, $payment); $this->_transaction = $transaction; }
/** * Dispatches an event to payment listeners * @param mixed $event Either a string, or an instance of jmsPaymentEvent * @return jmsPaymentEvent */ public final function dispatchEvent($event) { if (is_string($event)) { $event = new jmsPaymentEvent($event, $this); } if (!$event instanceof jmsPaymentEvent) { throw new InvalidArgumentException('$event must be a string representing the ' . 'name of the event, or an instance of jmsPaymentEvent.'); } // check if this payment has global handlers in this class before we // dispatch it to the registered listeners switch ($event->getName()) { case self::EVENT_PRE_TRANSACTION: $this->preTransactionEvent($event); break; case self::EVENT_POST_TRANSACTION: $this->postTransactionEvent($event); break; case self::EVENT_POST_STATE_CHANGE: $this->postStateChangeEvent($event); break; } // now dispatch the event to registered listeners foreach ($this->Listeners as $listener) { if ($event->isStopPropagation() === true) { break; } try { $listener->getHandler()->handlePaymentEvent($event); } catch (jmsPaymentEventHandlerDeletedException $e) { $this->unregisterListener($listener); } } return $event; }