src/controllers/CityController.php
public function actionList()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $parents = $this->getDepDropParents();
        if (count($parents) < 2) {
            $output = [];
        } else {
            $searchParents = ['country_id' => $parents[0]];
            if (isset($parents[1])) {
                $searchParents['state_id'] = $parents[1];
            } elseif (isset($parents[2])) {
                $searchParents['region_id'] = $parents[2];
            }
            $searchModel = new SearchCity($searchParents);
            $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
            $dataProvider->setPagination(false);
            $dataProvider->getSort()->defaultOrder = ['name' => SORT_ASC];
            $output = ArrayHelper::toArray($dataProvider->getModels(), ['id', 'name']);
        }
        return [
            'output' => $output
        ];
    }
public function actionList()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $parents = $this->getDepDropParents();
        if (count($parents) < 2) {
            $output = [];
        } else {
            $searchParents = ['country_id' => $parents[0]];
            if (isset($parents[1])) {
                $searchParents['state_id'] = $parents[1];
            } elseif (isset($parents[2])) {
                $searchParents['region_id'] = $parents[2];
            }
            $searchModel = new SearchCity($searchParents);
            $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
            $dataProvider->setPagination(false);
            $dataProvider->getSort()->defaultOrder = ['name' => SORT_ASC];
            $output = ArrayHelper::toArray($dataProvider->getModels(), ['id', 'name']);
        }
        return [
            'output' => $output
        ];
    }
Gets a json list of the countries in the database.

@return array