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


PHP Role::validate方法代码示例

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


在下文中一共展示了Role::validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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->aRole !== null) {
             if (!$this->aRole->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aRole->getValidationFailures());
             }
         }
         if ($this->aEmployee !== null) {
             if (!$this->aEmployee->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEmployee->getValidationFailures());
             }
         }
         if (($retval = UserPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:lejacome,项目名称:hospital-mgt,代码行数:37,代码来源:BaseUser.php

示例2: testAddingUserToRole

 public function testAddingUserToRole()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $role = new Role();
     $role->name = 'myRole';
     $role->validate();
     $saved = $role->save();
     $this->assertTrue($saved);
     $benny = User::getByUsername('benny');
     //Add the role to benny
     $benny->role = $role;
     $saved = $benny->save();
     $this->assertTrue($saved);
     $roleId = $role->id;
     unset($role);
     $role = Role::getById($roleId);
     $this->assertEquals(1, $role->users->count());
     $this->assertTrue($role->users[0]->isSame($benny));
     //Now try adding billy to the role but from the other side, from the role side.
     $billy = User::getByUsername('billy');
     $role->users->add($billy);
     $saved = $role->save();
     $this->assertTrue($saved);
     $billy->forget();
     //need to forget billy otherwise it won't pick up the change. i tried unset(), test fails
     $billy = User::getByUsername('billy');
     $this->assertTrue($billy->role->id > 0);
     $this->assertTrue($billy->role->isSame($role));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:29,代码来源:RoleTest.php

示例3: testGetRole

 public function testGetRole()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $role = new Role();
     $role->name = 'myRole';
     $role->validate();
     $saved = $role->save();
     $this->assertTrue($saved);
     $roles = Role::getAll();
     $compareData = $this->getModelToApiDataUtilData($roles[0]);
     $response = $this->createApiCallWithRelativeUrl('read/' . $compareData['id'], 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals($compareData, $response['data']);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:18,代码来源:ApiRestRoleTest.php

示例4: createRoles

 public static function createRoles()
 {
     foreach (self::$parentToChildRoleNames as $parentRoleName => $childRoleName) {
         if ($childRoleName !== null) {
             $childRole = new Role();
             $childRole->name = $childRoleName;
             $childRole->validate();
             $saved = $childRole->save();
             assert('$saved');
         }
         try {
             $parentRole = Role::getByName($parentRoleName);
         } catch (NotFoundException $e) {
             $parentRole = new Role();
         }
         $parentRole->name = $parentRoleName;
         if ($childRoleName !== null) {
             $parentRole->roles->add($childRole);
         }
         $saved = $parentRole->save();
         assert('$saved');
         $parentRole->forget();
         if ($childRoleName !== null) {
             $childRole->forget();
         }
     }
     foreach (self::$usernamesToUserInfo as $username => $userInfo) {
         $roleName = $userInfo[2];
         if ($roleName !== null) {
             assert('is_string($roleName)');
             $role = Role::getByName($roleName);
             $user = User::getByUsername($username);
             $role->users->add($user);
             $saved = $role->save();
             assert('$saved');
             $user->forget();
             //do this so that if you retrieve the $user, $user->role will be known.
         }
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:40,代码来源:SecurityTestHelper.php

示例5: 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->aDepartment !== null) {
             if (!$this->aDepartment->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aDepartment->getValidationFailures());
             }
         }
         if ($this->aDesignation !== null) {
             if (!$this->aDesignation->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aDesignation->getValidationFailures());
             }
         }
         if ($this->aRole !== null) {
             if (!$this->aRole->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aRole->getValidationFailures());
             }
         }
         if (($retval = EmployeePeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collDutyRostersRelatedByEmployeeId !== null) {
             foreach ($this->collDutyRostersRelatedByEmployeeId as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collDutyRostersRelatedBySubstituteId !== null) {
             foreach ($this->collDutyRostersRelatedBySubstituteId as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collUsers !== null) {
             foreach ($this->collUsers as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collVisitsRelatedByDoctorId !== null) {
             foreach ($this->collVisitsRelatedByDoctorId as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collVisitsRelatedByWardDocId !== null) {
             foreach ($this->collVisitsRelatedByWardDocId as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:lejacome,项目名称:hospital-mgt,代码行数:77,代码来源:BaseEmployee.php


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