本文整理汇总了PHP中Zend_Acl::getRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Acl::getRoles方法的具体用法?PHP Zend_Acl::getRoles怎么用?PHP Zend_Acl::getRoles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Acl
的用法示例。
在下文中一共展示了Zend_Acl::getRoles方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRoles
/**
* Returns the roles in the acl
*
* @return array roleId => ucfirst(roleId)
*/
public function getRoles()
{
$roles = array();
if ($this->acl) {
foreach ($this->acl->getRoles() as $role) {
//Do not translate, only make first one uppercase
$roles[$role] = ucfirst($role);
}
}
return $roles;
}
示例2: testgetRoles
/**
* @group ZF-8468
*/
public function testgetRoles()
{
$this->assertEquals(array(), $this->_acl->getRoles());
$roleGuest = new Role\GenericRole('guest');
$this->_acl->addRole($roleGuest);
$this->_acl->addRole(new Role\GenericRole('staff'), $roleGuest);
$this->_acl->addRole(new Role\GenericRole('editor'), 'staff');
$this->_acl->addRole(new Role\GenericRole('administrator'));
$expected = array('guest', 'staff', 'editor', 'administrator');
$this->assertEquals($expected, $this->_acl->getRoles());
}
示例3: getRolesByPrivilege
/**
* Returns the roles in the acl with the privilege
*
* @return array roleId => ucfirst(roleId)
*/
public function getRolesByPrivilege($privilege)
{
$roles = array();
if ($this->acl) {
foreach ($this->acl->getRoles() as $role) {
if ($this->acl->isAllowed($role, null, $privilege)) {
//Do not translate, only make first one uppercase
$roles[$role] = ucfirst($role);
}
}
}
return $roles;
}