Example #1
0
 /**
  * @param EventInterface $event
  * @param mixed callback
  * @param StateMachine $stateMachine
  *
  * @since Method available since Release 2.0.0
  */
 public function logActionCall(EventInterface $event, $payload, StateMachine $stateMachine)
 {
     foreach (debug_backtrace() as $stackFrame) {
         if ($stackFrame['function'] == 'runAction' || $stackFrame['function'] == 'evaluateGuard') {
             $calledBy = $stackFrame['function'];
         }
     }
     $this->actionCalls[] = array('state' => $stateMachine->getCurrentState()->getStateId(), 'event' => $event->getEventId(), 'calledBy' => @$calledBy);
 }
Example #2
0
 /**
  * @param EventInterface $event
  *
  * @throws InvalidEventException
  *
  * @since Method available since Release 2.0.0
  */
 public function setDoEvent(EventInterface $event)
 {
     if ($event->getEventId() != EventInterface::EVENT_DO) {
         throw new InvalidEventException(sprintf('The event "%s" is not a do event. "%s" must be set as the ID for an do event ', $event->getEventId(), EventInterface::EVENT_DO));
     }
     $this->eventCollection->add($event);
 }
Example #3
0
 /**
  * Invokes the action for the given event.
  *
  * @param EventInterface $event
  *
  * @since Method available since Release 2.0.0
  */
 private function invokeAction(EventInterface $event = null)
 {
     if ($event !== null && $event->getAction() !== null) {
         call_user_func($event->getAction(), $event, $this->getPayload(), $this);
     }
 }