LoadByIDOnlyName() public static méthode

public static LoadByIDOnlyName ( $id )
Exemple #1
0
 private function getBackupDetails($backupId)
 {
     $links = array();
     $backup = Scalr_Db_Backup::init()->loadById($backupId);
     $this->user->getPermissions()->validate($backup);
     $data = array('backup_id' => $backup->id, 'farm_id' => $backup->farmId, 'type' => ROLE_BEHAVIORS::GetName($backup->service) ? ROLE_BEHAVIORS::GetName($backup->service) : 'unknown', 'date' => Scalr_Util_DateTime::convertTz($backup->dtCreated), 'size' => $backup->size ? round($backup->size / 1024 / 1024, 2) : 0, 'provider' => $backup->provider, 'cloud_location' => $backup->cloudLocation, 'farmName' => DBFarm::LoadByIDOnlyName($backup->farmId));
     $downloadParts = $backup->getParts();
     foreach ($downloadParts as $part) {
         $part['size'] = $part['size'] ? round($part['size'] / 1024 / 1024, 2) : '';
         if ($part['size'] == 0) {
             $part['size'] = 0.01;
         }
         if ($data['provider'] == 's3') {
             $part['link'] = $this->getS3SignedUrl($part['path']);
         } else {
             if ($data['provider'] == 'cf') {
                 if ($backup->platform == SERVER_PLATFORMS::RACKSPACE) {
                     $part['link'] = $this->getCfSignedUrl($part['path'], $data['cloud_location'], $backup->platform);
                 } else {
                     $part['link'] = "swift://{$part['path']}";
                 }
             } else {
                 continue;
             }
         }
         $part['path'] = pathinfo($part['path']);
         $links[$part['number']] = $part;
     }
     $data['links'] = $links;
     return $data;
 }
Exemple #2
0
 /**
  * @param JsonData $sort
  * @param int $start
  * @param int $limit
  */
 public function xListAction(JsonData $sort, $start = 0, $limit = 20)
 {
     $result = ScriptShortcut::find(['farmId' => ['$in' => $this->getAllowedFarmId()]], null, Scalr\UI\Utils::convertOrder($sort, ['scriptId' => true], ['scriptId', 'farmId', 'farmRoleId']), $limit, $start, true);
     $data = [];
     foreach ($result as $shortcut) {
         /* @var $shortcut ScriptShortcut */
         $s = get_object_vars($shortcut);
         $s['farmName'] = DBFarm::LoadByIDOnlyName($shortcut->farmId);
         $s['scriptName'] = $shortcut->getScriptName();
         try {
             $farmRole = DBFarmRole::LoadByID($shortcut->farmRoleId);
             $s['farmRoleName'] = $farmRole->Alias ? $farmRole->Alias : $farmRole->GetRoleObject()->name;
         } catch (Exception $e) {
         }
         $data[] = $s;
     }
     $this->response->data(['total' => $result->totalNumber, 'data' => $data]);
 }