当前位置: 首页>>代码示例>>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;未经允许,请勿转载。