Ejemplo n.º 1
0
 /**
  * 
  * @param stdClass $input
  * @param stdClass $parentInput
  * @param GameAction $oGameAction
  * @return GameAction
  */
 public static function mapGameActionFromAPI($input, $parentInput, GameAction $oOutput = null)
 {
     $oGameActionType = NefubTypeMapper::mapTypeFromAPI($input->Type, 'GameActionType');
     $time = date('H:i:s', '00:' . strtotime($input->Time));
     if (!$oOutput) {
         $where = array('game_nefub_id' => $parentInput->ID, 'team_nefub_id' => $input->Team->ID, 'game_action_type_id' => $oGameActionType->getId(), 'period' => $input->Period, 'time' => $time);
         $oOutput = GameAction::getSingle($where);
         if (!$oOutput) {
             $oOutput = new GameAction();
         }
     }
     // Mapping
     $oOutput->time = $time;
     $oOutput->period = $input->Period;
     $oOutput->game_nefub_id = $parentInput->ID;
     $oOutput->team_nefub_id = $input->Team->ID;
     $oOutput->game_action_type_id = $oGameActionType->getId();
     $oOutput->code = $input->Code;
     $oOutput->description = $input->Description;
     if ($input->Person) {
         $oOutput->person_nefub_id = $input->Person->ID;
     }
     if ($input->Assist) {
         $oOutput->assist_person_nefub_id = $input->Assist->ID;
     }
     $oOutput->save();
     self::log('GameAction toegevoegd aan Game ' . $oOutput->game_nefub_id);
     return $oOutput;
 }