当前位置: 首页>>代码示例>>PHP>>正文


PHP Job::isHydrated方法代码示例

本文整理汇总了PHP中Job::isHydrated方法的典型用法代码示例。如果您正苦于以下问题:PHP Job::isHydrated方法的具体用法?PHP Job::isHydrated怎么用?PHP Job::isHydrated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Job的用法示例。


在下文中一共展示了Job::isHydrated方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getBotData

 /**
  * @param Bot $bot
  * @param Job $job
  * @return array
  */
 private function _getBotData($bot, $job)
 {
     $botData = array();
     $botData['id'] = $bot->id;
     $botData['name'] = $bot->getName();
     $botData['status'] = $bot->getStatus();
     $botData['status_class'] = BotStatus::getStatusHTMLClass($bot);
     $botData['url'] = $bot->getUrl();
     $botData['last_seen'] = BotLastSeen::getHTML($bot);
     $webcam = $bot->getWebCamImage();
     if ($webcam->isHydrated()) {
         $botData['webcam_url'] = $webcam->getDownloadURL();
     } else {
         $botData['webcam_url'] = "/img/colorbars.gif";
     }
     $buttons = $this->_getStatusButtons($bot);
     $menu = array();
     $status = $bot->getStatus();
     if ($status == BotState::Working) {
         $menu[] = $buttons['pause'];
         $menu[] = $buttons['dropjob'];
         $menu[] = $buttons['edit'];
         $menu[] = $buttons['delete'];
     } else {
         if ($status == BotState::Paused) {
             $menu[] = $buttons['play'];
             $menu[] = $buttons['dropjob'];
             $menu[] = $buttons['edit'];
             $menu[] = $buttons['delete'];
         } else {
             if ($status == BotState::Slicing) {
                 $menu[] = $buttons['dropjob'];
                 $menu[] = $buttons['edit'];
                 $menu[] = $buttons['delete'];
             } else {
                 if ($status == BotState::Waiting) {
                     $menu[] = $buttons['qa'];
                     $menu[] = $buttons['edit'];
                     $menu[] = $buttons['delete'];
                 } else {
                     if ($status == BotState::Idle) {
                         $menu[] = $buttons['offline'];
                         $menu[] = $buttons['edit'];
                         $menu[] = $buttons['error'];
                         $menu[] = $buttons['delete'];
                     } else {
                         if ($status == BotState::Offline) {
                             $menu[] = $buttons['online'];
                             $menu[] = $buttons['edit'];
                             $menu[] = $buttons['error'];
                             $menu[] = $buttons['delete'];
                             $menu[] = $buttons['retire'];
                         } else {
                             if ($status == BotState::Maintenance) {
                                 $menu[] = $buttons['online'];
                                 $menu[] = $buttons['offline'];
                                 $menu[] = $buttons['edit'];
                                 $menu[] = $buttons['delete'];
                             } else {
                                 if ($status == BotState::Error) {
                                     $menu[] = $buttons['online'];
                                     $menu[] = $buttons['offline'];
                                     $menu[] = $buttons['edit'];
                                     $menu[] = $buttons['delete'];
                                 } else {
                                     if ($status == BotState::Retired) {
                                         $menu[] = $buttons['delete'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $botData['menu'] = $menu;
     if ($job->isHydrated()) {
         $jobData = array();
         $jobData['id'] = $job->id;
         $jobData['name'] = $job->getName();
         $jobData['url'] = $job->getUrl();
         $jobData['status'] = $job->get('status');
         $jobData['status_class'] = JobStatus::getStatusHTMLClass($job->get('status'));
         $jobData['elapsed'] = $job->getElapsedText();
         $jobData['estimated'] = $job->getEstimatedText();
         if ($job->get('status') == 'taken' || $job->get('status') == 'slicing') {
             $jobData['progress'] = round($job->get('progress'), 2);
             $jobData['bar_class'] = "";
         }
         $temps = JSON::decode($bot->get('temperature_data'));
         if ($bot->get('status') == BotState::Working && $temps !== NULL) {
             if (isset($temps->extruder)) {
                 $botData['temp_extruder'] = $temps->extruder;
             }
//.........这里部分代码省略.........
开发者ID:eric116,项目名称:BotQueue,代码行数:101,代码来源:main.php

示例2: api_jobinfo

 public function api_jobinfo()
 {
     $job = new Job($this->args('job_id'));
     if (!$job->isHydrated()) {
         throw new Exception("Job does not exist.");
     }
     if (!$job->getQueue()->isMine()) {
         throw new Exception("This job is not in your queue.");
     }
     return $job->getAPIData();
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:11,代码来源:apiv1.php

示例3: ensureJobExists

 /**
  * @param Job $job
  * @throws Exception
  */
 private function ensureJobExists($job)
 {
     //did we really get someone?
     if (!$job->isHydrated()) {
         throw new Exception("Could not find that job.");
     }
 }
开发者ID:eric116,项目名称:BotQueue,代码行数:11,代码来源:job.php

示例4: update_sort

 public function update_sort()
 {
     $this->assertLoggedIn();
     if (!$this->args('jobs')) {
         die("Error: You didn't pass any jobs in.");
     }
     $jobs = explode(",", $this->args('jobs'));
     if (count($jobs) < 1) {
         die("Error: You need to pass in at least 2 jobs.");
     }
     //load up our ids.
     $jobIds = preg_filter('/^job_(\\d+)$/', '$1', $jobs);
     $jobs = array();
     // Only grab jobs that exist and are ours
     foreach ($jobIds as $id) {
         /** @var Job $job */
         $job = new Job($id);
         if ($job->isHydrated() && $job->isMine()) {
             $jobs[$id] = $job->get('user_sort');
         }
     }
     // Sort the values, but not the keys
     $values = array_values($jobs);
     sort($values);
     $jobs = array_combine(array_keys($jobs), $values);
     // Now actually update
     foreach ($jobs as $id => $sort) {
         /** @var Job $job */
         $job = new Job($id);
         $job->set('user_sort', $sort);
         $job->save();
     }
     die(print_r($jobs, true));
 }
开发者ID:eric116,项目名称:BotQueue,代码行数:34,代码来源:queue.php

示例5: create

 public function create()
 {
     $this->assertLoggedIn();
     if ($this->args('step2')) {
         $this->setTitle('Step 2 of 2: Create Job');
     } else {
         $this->setTitle('Create new Job');
     }
     try {
         if ($this->args('job_id')) {
             $job = new Job($this->args('job_id'));
             if (!$job->isHydrated()) {
                 throw new Exception("That job does not exist.");
             }
             if ($job->get('user_id') != User::$me->id) {
                 throw new Exception("You do not own this job.");
             }
             $file = $job->getFile();
             $queue_id = $job->get('queue_id');
         } else {
             $file = new S3File($this->args('file_id'));
         }
         if (!$file->isHydrated()) {
             throw new Exception("That file does not exist.");
         }
         if ($file->get('user_id') != User::$me->id) {
             throw new Exception("You do not have access to this file.");
         }
         $this->set('file', $file);
         //load up our form.
         $form = $this->_createJobForm($file, $queue_id);
         if (isset($job)) {
             $form->action = "/job/create/job:{$job->id}";
         } else {
             $form->action = "/job/create/file:{$file->id}";
         }
         //handle our form
         if ($form->checkSubmitAndValidate($this->args())) {
             //pull in our quantity
             $quantity = (int) $form->data('quantity');
             $quantity = max(1, $quantity);
             $quantity = min(1000, $quantity);
             //queue error checking.
             $queue = new Queue($form->data('queue_id'));
             if (!$queue->isHydrated()) {
                 throw new Exception("That queue does not exist.");
             }
             if (!$queue->canAdd()) {
                 throw new Exception("You do not have permission to add to that queue.");
             }
             //okay, we good?
             $queue->addGCodeFile($file, $quantity);
             Activity::log("added {$quantity} new " . Utility::pluralizeWord('job', $quantity));
             $this->forwardToUrl($queue->getUrl());
         }
         $this->set('form', $form);
     } catch (Exception $e) {
         $this->set('megaerror', $e->getMessage());
     }
 }
开发者ID:ricberw,项目名称:BotQueue,代码行数:60,代码来源:job.php


注:本文中的Job::isHydrated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。