本文整理匯總了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;
}