app\models\Project::getConf PHP Method

getConf() public static method

获取当前进程的项目配置
public static getConf ( $id = null ) : string | ActiveQuery
$id
return string | yii\db\ActiveQuery
    public static function getConf($id = null)
    {
        if (empty(static::$CONF)) {
            static::$CONF = static::findOne($id);
        }
        return static::$CONF;
    }

Usage Example

Example #1
0
 /**
  * 提交任务
  *
  * @param $projectId 没有projectId则显示列表
  * @return string
  */
 public function actionSubmit($projectId = null)
 {
     if (!$projectId) {
         // 显示所有项目列表
         $projects = Project::find()->leftJoin(Group::tableName(), '`group`.`project_id`=`project`.`id`')->where(['project.status' => Project::STATUS_VALID, '`group`.`user_id`' => $this->uid])->asArray()->all();
         return $this->render('select-project', ['projects' => $projects]);
     }
     $task = new Task();
     $conf = Project::getConf($projectId);
     if (!$conf) {
         throw new \Exception(yii::t('task', 'unknown project'));
     }
     if (\Yii::$app->request->getIsPost()) {
         $group = Group::find()->where(['user_id' => $this->uid, 'project_id' => $projectId])->count();
         if (!$group) {
             throw new \Exception(yii::t('task', 'you are not the member of project'));
         }
         if ($task->load(\Yii::$app->request->post())) {
             // 是否需要审核
             $status = $conf->audit == Project::AUDIT_YES ? Task::STATUS_SUBMIT : Task::STATUS_PASS;
             $task->user_id = $this->uid;
             $task->project_id = $projectId;
             $task->status = $status;
             $task->file_list = implode("\n", (array) $task->file_list);
             if ($task->save()) {
                 return $this->redirect('@web/task/');
             }
         }
     }
     $tpl = $conf->repo_type == Project::REPO_GIT ? 'submit-git' : 'submit-svn';
     return $this->render($tpl, ['task' => $task, 'conf' => $conf]);
 }
All Usage Examples Of app\models\Project::getConf