Exemplo n.º 1
0
 /**
  * Инициирует события заданного перехода
  *
  * @param  integer             $type
  * @param  object              $object
  * @param  SignalInterface     $signal
  * @param  TransitionInterface $transition
  * @return void
  */
 private function handleEvents(int $type, object $object, SignalInterface $signal, TransitionInterface $transition)
 {
     switch ($type) {
         case static::EVENT_TYPE_PRE:
             $events1 = $signal->getPreEvents();
             $events2 = $transition->getPreEvents();
             break;
         case static::EVENT_TYPE_POST:
             $events1 = $transition->getPostEvents();
             $events2 = $signal->getPostEvents();
             break;
         default:
             throw $this->createInvalidEventTypeException($type);
     }
     $previous = $transition->getPrevious();
     $next = $transition->getNext();
     $parameters = $signal->getParameters();
     $signal = $signal->getName();
     $machine = $this->name;
     foreach (array_merge(array_values($events1), array_values($events2)) as $event) {
         $this->events->trigger($object, $previous, $next, $event, $machine, $signal, $parameters);
     }
 }
 /**
  * Обрабатывает событие
  *
  * @param  object $object
  * @param  string $previous
  * @param  string $next
  * @param  string $event
  * @param  string $machine
  * @param  string $signal
  * @param  array  $parameters
  * @return void
  */
 public function trigger(object $object, string $previous, string $next, string $event, string $machine, string $signal, array $parameters)
 {
     $event = new ZendEvent($object, $previous, $next, $event, $machine, $signal, $parameters);
     $this->events->triggerEvent($event);
 }