示例#1
0
 /**
  * @param $symbol
  * @return CycleEvent
  */
 private function createCycleEvent($symbol)
 {
     $cycleEvent = new CycleEvent();
     $cycleEvent->setCycleLoop($this);
     $cycleEvent->setInputSymbol($symbol);
     return $cycleEvent;
 }
示例#2
0
 /**
  * @param CycleEvent $cycleEvent
  * @return bool
  * @throws CycleInputException
  */
 public function handleEventInput(CycleEvent $cycleEvent)
 {
     if (!$this->inputSchema) {
         throw new CycleInputException('Key Schema has not set.');
     }
     $isMatched = false;
     $schema = $this->inputSchema->getSchema();
     foreach ($schema as $symbol => $keyDescription) {
         if ($symbol !== $cycleEvent->getInputSymbol()) {
             continue;
         }
         $isMatched = true;
         $class = $keyDescription->getClass();
         $methodName = $keyDescription->getMethodName();
         if (!is_callable(array($class, $methodName))) {
             throw new CycleInputException('KeyControll method %s::%s not callable.', get_class($class), $methodName);
         }
         call_user_func_array(array($class, $methodName), [$cycleEvent, $keyDescription]);
     }
     return $isMatched;
 }