public function actionNext() { $params = Yii::$app->getRequest()->getBodyParams(); $testId = $params['testId']; $result = ['word' => '', 'translates' => [], 'language' => '', 'success' => false]; $test = Test::findOne($testId); if (!$test) { // The client supplied a wrong test ID! $result['message'] = 'The test was not found'; return $result; } $next = Dictionary::next($testId); if (!count($next)) { return $result; } $next['success'] = true; return $next; }