本文整理匯總了PHP中Time::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Time::validate方法的具體用法?PHP Time::validate怎麽用?PHP Time::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Time
的用法示例。
在下文中一共展示了Time::validate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testValidateNull
/**
* @covers Gacela\Field\Time::validate
* @dataProvider providerNull
*/
public function testValidateNull($meta, $value, $in)
{
$this->assertEquals(Time::NULL_CODE, $this->object->validate($meta, $value));
}
示例2: testValidate14
/**
* Generated from @assert (NULL) === false.
*
* @covers pgn\tags\Time::validate
*/
public function testValidate14()
{
$this->assertSame(false, $this->object->validate(NULL));
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'show' page.
*/
public function actionCreate()
{
$model = new Time($this->action->id);
if (isset($_POST['Time'])) {
// collect user input data
$model->attributes = $_POST['Time'];
if (!isset($_POST['Time']['managerId'])) {
// set manager based on the task
if ($model->taskId >= 1) {
$criteria = new CDbCriteria();
$criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC";
if (($user2Task = User2Task::model()->findByAttributes(array('taskId' => $model->taskId, 'role' => User2Task::MANAGER), $criteria)) !== null) {
$model->managerId = $user2Task->userId;
} else {
$model->managerId = 0;
}
} else {
$model->managerId = 0;
}
}
if (!isset($_POST['Time']['consultantId'])) {
// set consultant based on the task
if ($model->taskId >= 1) {
$criteria = new CDbCriteria();
$criteria->order = "`t`.`userPriority` ASC, `t`.`id` ASC";
if (($user2Task = User2Task::model()->findByAttributes(array('taskId' => $model->taskId, 'role' => User2Task::CONSULTANT), $criteria)) !== null) {
$model->consultantId = $user2Task->userId;
} else {
$model->consultantId = 0;
}
} else {
$model->consultantId = 0;
}
}
// validate with the current action as scenario and save without validation
if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
// set success message
MUserFlash::setTopSuccess(Yii::t('hint', 'The new "{title}" time 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)
if (Yii::app()->user->checkAccess(User::MANAGER) || Yii::app()->user->checkAccess(User::ADMINISTRATOR)) {
$model->isConfirmed = Time::IS_CONFIRMED;
}
if (isset($_GET['taskId'])) {
// task is known
$model->taskId = $_GET['taskId'];
}
}
$this->render($this->action->id, array('model' => $model));
}