private function runGetImpl2(Battle $battle, array $deathReasons, array $players = null, Agent $agent = null) { $ret = $battle->toJsonArray(); $ret['death_reasons'] = array_map(function ($model) { return $model->toJsonArray(); }, $deathReasons); $ret['players'] = is_array($players) && !empty($players) ? array_map(function ($model) { return $model->toJsonArray(); }, $players) : null; $ret['agent']['name'] = $agent ? $agent->name : null; $ret['agent']['version'] = $agent ? $agent->version : null; $resp = Yii::$app->getResponse(); $resp->format = 'json'; return $ret; }