/** * Populate available Sites from a Provider. */ public function apiGetSites() { $user_uuid = drush_cache_get('user_uuid', $this->drushCacheBinAuthName()); $result = switchboard_request($this, array('method' => 'GET', 'realm' => 'sites', 'resource' => 'user', 'uuid' => $user_uuid->data)); $site_metadata = json_decode($result->body); $sites = array(); foreach ($site_metadata as $uuid => $data) { $site = SiteQuery::create()->filterByProvider($this->name)->filterByName($data->information->name)->findOne(); if (!$site) { $site = new Site(); $site->setProvider($this->name); $site->setName($data->information->name); } $site->setUuid($uuid); $site->setRealm($data->information->preferred_zone); $site->save(); } }
/** * Populate available Sites from a Provider. */ public function apiGetSites() { $result = switchboard_request($this, array('method' => 'GET', 'resource' => '/sites')); $site_names = json_decode($result->body); $sites = array(); foreach ($site_names as $site_data) { list($realm, $site_name) = explode(':', $site_data); $site = SiteQuery::create()->filterByProvider($this->name)->filterByName($site_name)->findOne(); if (!$site) { $site = new Site(); $site->setProvider($this->name); $site->setName($site_name); } $site->setRealm($realm); $site->save(); } }