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


PHP Task::validate方法代码示例

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


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

示例1: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aTaskRelatedByTaskId !== null) {
             if (!$this->aTaskRelatedByTaskId->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aTaskRelatedByTaskId->getValidationFailures());
             }
         }
         if ($this->aTaskRelatedByOverrideTaskId !== null) {
             if (!$this->aTaskRelatedByOverrideTaskId->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aTaskRelatedByOverrideTaskId->getValidationFailures());
             }
         }
         if ($this->aUser !== null) {
             if (!$this->aUser->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
             }
         }
         if (($retval = OverrideTaskPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:snoopckuu,项目名称:prmanagment,代码行数:42,代码来源:BaseOverrideTask.php

示例2: store

 public static function store()
 {
     parent::check_logged_in();
     // POST-pyynnön muuttujat sijaitsevat $_POST nimisessä assosiaatiolistassa
     $params = $_POST;
     // Alustetaan uusi task-luokan olion käyttäjän syöttämillä arvoilla
     /*$task = new task(array(
       'name' => $params['name'],
       'description' => $params['description'],
       'publisher' => $params['publisher'],
       'published' => $params['published']
       ));*/
     $params['user_id'] = parent::get_user_logged_in()->id;
     $task = new Task($params);
     $errors = $task->validate();
     if (!$errors) {
         // Kutsutaan alustamamme olion save metodia, joka tallentaa olion tietokantaan
         $task->save();
         // Ohjataan käyttäjä lisäyksen jälkeen pelin esittelysivulle
         //Redirect::to('/task/' . $task->id, array('message' => 'Task has been added!'));
         Redirect::to('/task', array('message' => 'Task has been added!'));
     } else {
         View::make('task/new.html', array('errors' => $errors, 'attributes' => $params, 'title' => 'new task'));
     }
 }
开发者ID:tuureilmarinen,项目名称:tsoha,代码行数:25,代码来源:task_controller.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $task = new Task();
     $task->unguard();
     $task->fill(Input::only(['name', 'user_id', 'description', 'status']));
     $task->deadline = new DateTime(Input::get('deadline'));
     if ($task->validate()) {
         $task->save();
     } else {
         return View::make('tasks.edit', ['task' => $task])->withErrors($task->validator());
     }
     return Redirect::to(route('tasks.index'))->with('message', ['content' => 'Taak met succes aangemaakt!', 'class' => 'success']);
 }
开发者ID:y0sh1,项目名称:logboek,代码行数:18,代码来源:TasksController.php

示例4: actionIndex

 public function actionIndex()
 {
     $models = array();
     if (!empty($_POST['Task'])) {
         foreach ($_POST['Task'] as $taskData) {
             $model = new Task();
             $model->setAttributes($taskData);
             if ($model->validate()) {
                 $models[] = $model;
             }
         }
     }
     if (!empty($models)) {
         // We've received some models and validated them.
         // If you want to save the data you can do it here.
     } else {
         $models[] = new Task();
     }
     $this->render('index', array('models' => $models));
 }
开发者ID:moohwaan,项目名称:yii-application-cookbook-2nd-edition-code,代码行数:20,代码来源:TaskController.php

示例5: function

 // Delete list by ID
 Route::delete('lists/{id}', function ($id) {
     $list = TaskList::findByOwnerAndId(Auth::user(), $id);
     $list->delete();
     return Response::make(null, 204);
 })->where('id', '\\d+');
 // Get tasks for list
 Route::get('lists/{id}/tasks', function ($id) {
     $list = TaskList::findByOwnerAndId(Auth::user(), $id);
     return Response::json($list->tasks->toArray());
 })->where('id', '\\d+');
 // Create task
 Route::post('lists/{id}/tasks', function ($id) {
     $list = TaskList::findByOwnerAndId(Auth::user(), $id);
     $task = new Task(Input::get());
     $task->validate();
     $task->list_id = $id;
     if (!$task->save()) {
         App::abort(500, 'Task was not saved');
     }
     return Response::json($task->toArray(), 201);
 })->where('id', '\\d+');
 // Get task by ID
 Route::get('lists/{list_id}/tasks/{id}', function ($list_id, $id) {
     $list = TaskList::findByOwnerAndId(Auth::user(), $list_id);
     $task = $list->tasks()->find($id);
     if (!$task) {
         App::abort(404);
     }
     return Response::json($task->toArray());
 })->where('list_id', '\\d+')->where('id', '\\d+');
开发者ID:esmaieldanish,项目名称:laracon-todo-api,代码行数:31,代码来源:routes.php

示例6: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Task($this->action->id);
     if (isset($_POST['Task'])) {
         // collect user input data
         $model->attributes = $_POST['Task'];
         if (!isset($_POST['Task']['companyId'])) {
             // set company based on the project
             if ($model->projectId >= 1) {
                 $criteria = new CDbCriteria();
                 $criteria->order = "`t`.`companyPriority` ASC, `t`.`id` ASC";
                 if (($company2Project = Company2Project::model()->findByAttributes(array('projectId' => $model->projectId), $criteria)) !== null) {
                     $model->companyId = $company2Project->companyId;
                 } else {
                     $model->companyId = 0;
                 }
             } else {
                 $model->companyId = 0;
             }
         }
         if ($model->projectId >= 1) {
             // set project's hourly rate
             if (($project = Project::model()->findByPk($model->projectId)) !== null) {
                 $model->hourlyRate = $project->hourlyRate;
             }
         }
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             if (isset($_POST['User2Task'])) {
                 // assigned consultants
                 $model->allConsultant2Task = array(0 => new User2Task('create'));
                 $model->allConsultant2Task[0]->taskId = $model->id;
                 foreach ($model->allConsultant2Task as $user2Task) {
                     $user2Task->attributes = $_POST['User2Task'];
                     $user2Task->save();
                 }
             }
             if ($model->projectId >= 1) {
                 // new relation between task and manager
                 $criteria = new CDbCriteria();
                 $criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC";
                 if (($user2Project = User2Project::model()->findByAttributes(array('projectId' => $model->projectId, 'role' => User2Project::MANAGER), $criteria)) !== null) {
                     $user2Task = new User2Task('create');
                     $user2Task->userId = $user2Project->userId;
                     $user2Task->taskId = $model->id;
                     $user2Task->role = User2Task::MANAGER;
                     $user2Task->save();
                 }
             }
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" task record has been successfully created.', array('{title}' => MHtml::wrapInTag($model->title, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     } else {
         // pre-assigned attributes (default values for a new record)
         $model->dueDate = MDate::formatToDb(time() + 14 * 86400, 'date');
         $model->openDate = MDate::formatToDb(time(), 'date');
         $model->priority = Task::PRIORITY_MEDIUM;
         $model->status = Task::NOT_STARTED;
         if (Yii::app()->user->checkAccess(User::MANAGER) || Yii::app()->user->checkAccess(User::ADMINISTRATOR)) {
             $model->isConfirmed = Task::IS_CONFIRMED;
         }
         if (isset($_GET['projectId'])) {
             // project is known
             $model->projectId = $_GET['projectId'];
         }
     }
     if (!isset($model->allConsultant2Task[0])) {
         // new associated consultant
         $model->allConsultant2Task = array(0 => new User2Task('create'));
         $model->allConsultant2Task[0]->taskId = $model->id;
         $model->allConsultant2Task[0]->role = User2Task::CONSULTANT;
     }
     $this->render($this->action->id, array('model' => $model));
 }
开发者ID:megabr,项目名称:web3cms,代码行数:80,代码来源:TaskController.php


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