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


PHP Role::getNewInstance方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     $this->role = Role::getNewInstance('__testrole__');
     $this->role->save();
     $this->userGroup = UserGroup::getNewInstance('Any random group name');
     $this->userGroup->save();
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:AccessControlAssociationTest.php

示例2: testGetRoleByName

 public function testGetRoleByName()
 {
     $newRole = Role::getNewInstance('testing');
     $newRole->save();
     $role = Role::getInstanceByName('testing');
     $this->assertSame($role, $newRole);
     $role = Role::getInstanceByName('unknown');
     $this->assertNull($role, null);
 }
开发者ID:saiber,项目名称:livecart,代码行数:9,代码来源:RoleTest.php

示例3: testHasConcreteAccess

 public function testHasConcreteAccess()
 {
     $group = UserGroup::getNewInstance('testing1337', 'testing1337');
     $group->save();
     $role = Role::getNewInstance('testing1337.update');
     $role->save();
     $group->applyRole($role);
     $group->save();
     $this->assertFalse($group->hasAccess('testing1337'));
     $this->assertTrue($group->hasAccess('testing1337.update'));
     $this->assertFalse($group->hasAccess('testing1337.create'));
 }
开发者ID:saiber,项目名称:livecart,代码行数:12,代码来源:UserGroupTest.php

示例4: addNewRolesNames

 public static function addNewRolesNames($roleNames, $deleteOther = false)
 {
     // unset meta- roles
     if ($i = array_search('login', $roleNames)) {
         unset($roleNames[$i]);
     }
     if (!is_array($roleNames) || empty($roleNames)) {
         return;
     }
     $filter = new ARSelectFilter();
     $deleteFilter = new ARDeleteFilter();
     $condition = new EqualsCond(new ARFieldHandle(__CLASS__, "name"), $roleNames[0]);
     $deleteCondition = new NotEqualsCond(new ARFieldHandle(__CLASS__, "name"), $roleNames[0]);
     foreach ($roleNames as $roleName) {
         $condition->addOR(new EqualsCond(new ARFieldHandle(__CLASS__, "name"), $roleName));
         $deleteCondition->addAnd(new NotEqualsCond(new ARFieldHandle(__CLASS__, "name"), $roleName));
     }
     $filter->setCondition($condition);
     $deleteFilter->setCondition($deleteCondition);
     if ($deleteOther) {
         self::deleteRecordSet(__CLASS__, $deleteFilter);
     }
     // Find new roles
     $invertedRoleNames = array_flip($roleNames);
     foreach (self::getRecordSet($filter) as $role) {
         if (isset($invertedRoleNames[$role->name->get()])) {
             unset($invertedRoleNames[$role->name->get()]);
         }
     }
     // Add new roles to database
     foreach ($invertedRoleNames as $role => $value) {
         if (!empty($role)) {
             $newRole = Role::getNewInstance($role);
             $newRole->save();
         }
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:37,代码来源:Role.php


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