/** * Returns the favorite locations for current user * * @return mixed */ public function getFavoriteLocationsAction() { $this->view->disable(); $user_id = $this->auth->isUserSignedIn() ? $this->auth->getIdentity()['id'] : 17; // $this->request->getPost('user_id'); $favorites = Favorites::find(['user_id = :user_id:', 'bind' => ['user_id' => $user_id]]); $ids = []; foreach ($favorites as $f) { $ids[] = $f->getLocationId(); } $weather = new Weather(); $cityVars = $weather->getCitiesInfo($ids); $cities = json_decode($cityVars); $result = []; foreach ($cities->list as $key => $city) { $result[$key]['city'] = $city->name; $result[$key]['temperature'] = $city->main->temp; $result[$key]['icon'] = $city->weather[0]->icon; } $this->response->setContent(json_encode($result)); return $this->response; }