當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Task::findOne方法代碼示例

本文整理匯總了PHP中app\models\Task::findOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP Task::findOne方法的具體用法?PHP Task::findOne怎麽用?PHP Task::findOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Task的用法示例。


在下文中一共展示了Task::findOne方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionStartDeploy

 /**
  * 發起上線
  *
  * @throws \Exception
  */
 public function actionStartDeploy()
 {
     $taskId = \Yii::$app->request->post('taskId');
     if (!$taskId) {
         $this->renderJson([], -1, '任務號不能為空:)');
     }
     $this->task = Task::findOne($taskId);
     if (!$this->task) {
         throw new \Exception('任務號不存在:)');
     }
     if ($this->task->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的任務:)');
     }
     // 任務失敗或者審核通過時可發起上線
     if (!in_array($this->task->status, [Task::STATUS_PASS, Task::STATUS_FAILED])) {
         throw new \Exception('任務不能被重複執行:)');
     }
     // 項目配置
     $this->conf = Project::getConf($this->task->project_id);
     $this->walleTask = new WalleTask($this->conf);
     $this->walleFolder = new Folder($this->conf);
     try {
         if ($this->task->action == Task::ACTION_ONLINE) {
             $this->_makeVersion();
             $this->_initWorkspace();
             $this->_preDeploy();
             $this->_gitUpdate();
             $this->_postDeploy();
             $this->_rsync();
             $this->_updateRemoteServers($this->task->link_id);
             $this->_cleanRemoteReleaseVersion();
             $this->_cleanUpLocal($this->task->link_id);
         } else {
             $this->_rollback($this->task->ex_link_id);
         }
         /** 至此已經發布版本到線上了,需要做一些記錄工作 */
         // 記錄此次上線的版本(軟鏈號)和上線之前的版本
         ///對於回滾的任務不記錄線上版本
         if ($this->task->action == Task::ACTION_ONLINE) {
             $this->task->ex_link_id = $this->conf->version;
         }
         // 第一次上線的任務不能回滾、回滾的任務不能再回滾
         if ($this->task->action == Task::ACTION_ROLLBACK || $this->task->id == 1) {
             $this->task->enable_rollback = Task::ROLLBACK_FALSE;
         }
         $this->task->status = Task::STATUS_DONE;
         $this->task->save();
         // 可回滾的版本設置
         $this->_enableRollBack();
         // 記錄當前線上版本(軟鏈)回滾則是回滾的版本,上線為新版本
         $this->conf->version = $this->task->link_id;
         $this->conf->save();
     } catch (\Exception $e) {
         $this->task->status = Task::STATUS_FAILED;
         $this->task->save();
         // 清理本地部署空間
         $this->_cleanUpLocal($this->task->link_id);
         throw $e;
     }
 }
開發者ID:ShuangRen,項目名稱:walle-web,代碼行數:65,代碼來源:WalleController.php

示例2: saveAssign

 private function saveAssign($new_assign, $send_notification)
 {
     $model = Task::findOne($this->id);
     $old_assigned = $model->getAssignedToArray();
     if ($old_assigned) {
         if (!$new_assign) {
             return self::deleteAssign($old_assigned);
         }
         //remove elementos a mais
         $to_delete = array_diff($old_assigned, $new_assign);
         if ($to_delete && !self::deleteAssign($to_delete)) {
             return false;
         }
         $to_create = array_diff($new_assign, $old_assigned);
         if ($to_create && !self::createAssign($to_create, $send_notification)) {
             return false;
         }
     } else {
         if ($new_assign) {
             //Cria novo
             return self::createAssign($new_assign, $send_notification);
         }
     }
     return true;
 }
開發者ID:afernandes465,項目名稱:memoboard,代碼行數:25,代碼來源:Task.php

示例3: actionTaskOperation

 /**
  * 任務審核
  *
  * @param $id
  * @param $operation
  */
 public function actionTaskOperation($id, $operation)
 {
     $task = Task::findOne($id);
     if (!$task) {
         static::renderJson([], -1, '任務號不存在');
     }
     // 是否為該項目的審核管理員(超級管理員可以不用審核,如果想審核就得設置為審核管理員,要不隻能維護配置)
     if (!Group::isAuditAdmin($this->uid, $task->project_id)) {
         throw new \Exception('不可以操作其它人的任務:)');
     }
     $task->status = $operation ? Task::STATUS_PASS : Task::STATUS_REFUSE;
     $task->save();
     static::renderJson(['status' => \Yii::t('status', 'task_status_' . $task->status)]);
 }
開發者ID:ShuangRen,項目名稱:walle-web,代碼行數:20,代碼來源:TaskController.php

示例4: actionStartDeploy

 /**
  * 發起上線
  *
  * @throws \Exception
  */
 public function actionStartDeploy()
 {
     $taskId = \Yii::$app->request->post('taskId');
     if (!$taskId) {
         $this->renderJson([], -1, yii::t('walle', 'deployment id is empty'));
     }
     $this->task = Task::findOne($taskId);
     if (!$this->task) {
         throw new \Exception(yii::t('walle', 'deployment id not exists'));
     }
     if ($this->task->user_id != $this->uid) {
         throw new \Exception(yii::t('w', 'you are not master of project'));
     }
     // 任務失敗或者審核通過時可發起上線
     if (!in_array($this->task->status, [Task::STATUS_PASS, Task::STATUS_FAILED])) {
         throw new \Exception(yii::t('walle', 'deployment only done for once'));
     }
     // 清除曆史記錄
     Record::deleteAll(['task_id' => $this->task->id]);
     // 項目配置
     $this->conf = Project::getConf($this->task->project_id);
     $this->walleTask = new WalleTask($this->conf);
     $this->walleFolder = new Folder($this->conf);
     try {
         if ($this->task->action == Task::ACTION_ONLINE) {
             $this->_makeVersion();
             $this->_initWorkspace();
             $this->_preDeploy();
             $this->_revisionUpdate();
             $this->_postDeploy();
             $this->_transmission();
             $this->_updateRemoteServers($this->task->link_id, $this->conf->post_release_delay);
             $this->_cleanRemoteReleaseVersion();
             $this->_cleanUpLocal($this->task->link_id);
         } else {
             $this->_rollback($this->task->ex_link_id);
         }
         /** 至此已經發布版本到線上了,需要做一些記錄工作 */
         // 記錄此次上線的版本(軟鏈號)和上線之前的版本
         ///對於回滾的任務不記錄線上版本
         if ($this->task->action == Task::ACTION_ONLINE) {
             $this->task->ex_link_id = $this->conf->version;
         }
         // 第一次上線的任務不能回滾、回滾的任務不能再回滾
         if ($this->task->action == Task::ACTION_ROLLBACK || $this->task->id == 1) {
             $this->task->enable_rollback = Task::ROLLBACK_FALSE;
         }
         $this->task->status = Task::STATUS_DONE;
         $this->task->save();
         // 可回滾的版本設置
         $this->_enableRollBack();
         // 記錄當前線上版本(軟鏈)回滾則是回滾的版本,上線為新版本
         $this->conf->version = $this->task->link_id;
         $this->conf->save();
     } catch (\Exception $e) {
         $this->task->status = Task::STATUS_FAILED;
         $this->task->save();
         // 清理本地部署空間
         $this->_cleanUpLocal($this->task->link_id);
         throw $e;
     }
     $this->renderJson([]);
 }
開發者ID:charlestang,項目名稱:walle-web,代碼行數:68,代碼來源:WalleController.php

示例5: actionTaskOperation

 /**
  * 任務審核
  *
  * @param $id
  * @param $operation
  */
 public function actionTaskOperation($id, $operation)
 {
     $task = Task::findOne($id);
     if (!$task) {
         static::renderJson([], -1, '任務號不存在');
     }
     $task->status = $operation ? Task::STATUS_PASS : Task::STATUS_REFUSE;
     $task->save();
     static::renderJson(['status' => \Yii::t('status', 'task_status_' . $task->status)]);
 }
開發者ID:uedzen,項目名稱:walle-web,代碼行數:16,代碼來源:TaskController.php

示例6: actionDeploy

 /**
  * 上線管理
  *
  * @param $taskId
  * @return string
  * @throws \Exception
  */
 public function actionDeploy($taskId)
 {
     $this->task = Task::findOne($taskId);
     if (!$this->task) {
         throw new \Exception('任務號不存在:)');
     }
     if ($this->task->user_id != $this->uid) {
         throw new \Exception('不可以操作其它人的任務:)');
     }
     return $this->render('deploy', ['task' => $this->task]);
 }
開發者ID:royalwang,項目名稱:walle-web,代碼行數:18,代碼來源:WalleController.php

示例7: findModel

 /**
  * Finds the Task model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Task the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($role = priviledge::getRole()) == 'Admin') {
         if (($model = Task::findOne($id)) !== null) {
             return $model;
         } else {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
開發者ID:andrenovelando,項目名稱:firewall-webapps,代碼行數:19,代碼來源:TaskController.php

示例8: actionTaskEdit

 public function actionTaskEdit()
 {
     if (isset($_GET['task_id'])) {
         $task = Task::findOne($_GET['task_id']);
     } else {
         $task = new Task();
     }
     /**
      * @var Task $task
      */
     if (!empty($_POST)) {
         $task = TaskManager::editTask($task, $_POST['time'], $_POST['command'], $_POST['status'], $_POST['comment']);
     }
     return $this->render('task_edit', array('task' => $task, 'methods' => TaskLoader::getAllMethods(self::$tasks_controllers_folder, self::$tasks_namespace)));
 }
開發者ID:e-tipalchuk,項目名稱:cron-manager,代碼行數:15,代碼來源:TasksController.php

示例9: findModelReplyTask

 protected function findModelReplyTask($id)
 {
     if (($model = Task::findOne(['id' => $id, 'task_to' => Yii::$app->user->id])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
開發者ID:nicovicz,項目名稱:portalctv,代碼行數:8,代碼來源:TaskController.php

示例10: actionDelete

 /**
  * Удаление определенной записи
  * @param  integer $id Идентификатор удаляемой записи
  * @return redirect
  */
 public function actionDelete($id)
 {
     //Определение текущего языка
     SiteController::locale();
     //Поиск задания по идентификатору
     $task = Task::findOne($id);
     //Удаление всех связанных с заданием комментариев
     $commentDeleted = Comment::deleteAll(["task_id" => $id]);
     if ($task->delete()) {
         Yii::$app->session->setFlash('success', Yii::t('msg/msg', 'Запись удалена'));
         return $this->redirect("/");
     } else {
         Yii::$app->session->setFlash('errors', $task->errors);
     }
 }
開發者ID:rikosage,項目名稱:to-do-list-v2,代碼行數:20,代碼來源:TaskController.php

示例11: actionDelete

 public function actionDelete($id)
 {
     $model = Task::findOne($id);
     TaskAssign::deleteAll(['task_id' => $id]);
     $model->delete();
     return $this->redirect('user');
 }
開發者ID:afernandes465,項目名稱:memoboard,代碼行數:7,代碼來源:TaskController.php

示例12: actionTaskEdit

 public function actionTaskEdit()
 {
     if (isset($_GET['task_id'])) {
         $task = Task::findOne($_GET['task_id']);
     } else {
         $task = new Task();
     }
     /**
      * @var Task $task
      */
     $post = \Yii::$app->request->post();
     if ($task->load($post) && $task->validate()) {
         $task = TaskManager::editTask($task, $post['Task']['time'], $post['Task']['command'], $post['Task']['status'], $post['Task']['comment']);
         \Yii::$app->response->redirect('/?r=tasks/task-edit&task_id=' . $task->task_id);
     }
     return $this->render('task_edit', array('task' => $task, 'methods' => TaskLoader::getAllMethods(self::$tasks_controllers_folder, self::$tasks_namespace)));
 }
開發者ID:MUlt1mate,項目名稱:cron-manager,代碼行數:17,代碼來源:TasksController.php

示例13: actionTasked

 /**
  * Сохранение задачи
  * @return string
  * @throws \Exception
  */
 public function actionTasked()
 {
     if (Yii::$app->getRequest()->getQueryParam('user')) {
         $user = Yii::$app->getRequest()->getQueryParam('user');
         if (Yii::$app->getRequest()->getQueryParam('task_id') !== null && Yii::$app->getRequest()->getQueryParam('mark') !== null) {
             //return var_dump($user);
             $task = Task::findOne(Yii::$app->getRequest()->getQueryParam('task_id'));
             $task->status = 2;
             $task->update();
             $act = new DiaryActs();
             $act->model_id = 2;
             $act->user_id = (int) $user;
             $act->mark = (int) Yii::$app->getRequest()->getQueryParam('mark');
             $act->mark_status = 0;
             if ($act->save(false)) {
                 $tasked = new Tasked();
                 $tasked->task_id = $task->id;
                 $tasked->user_id = (int) $user;
                 $tasked->act_id = $act->id;
                 $tasked->mark = (int) Yii::$app->getRequest()->getQueryParam('mark');
                 $tasked->mark_status = 0;
                 //return var_dump($tasked);
                 if ($tasked->save()) {
                     return "<span style='color:green'>Задача выполнена!</span>";
                 } else {
                     "<span style='color:red'>Ошибка сохранения tasked</span>";
                 }
             } else {
                 return "<span style='color:red'>Ошибка валидации</span>";
             }
         }
     }
 }
開發者ID:roman1970,項目名稱:lis,代碼行數:38,代碼來源:DefaultController.php

示例14: actionDelete

 public function actionDelete($id)
 {
     Task::findOne($id)->deleteRecursive();
     Yii::$app->getSession()->setFlash("success", 'The record was deleted.');
     return $this->redirect(["task/"]);
 }
開發者ID:JamesBarnsley,項目名稱:Neptune,代碼行數:6,代碼來源:TaskController.php

示例15: findModel

 /**
  * Finds the Task model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Task the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Task::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
開發者ID:alxkolm,項目名稱:php-selftop,代碼行數:15,代碼來源:TaskController.php


注:本文中的app\models\Task::findOne方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。