本文整理汇总了PHP中ACLRole::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ACLRole::toArray方法的具体用法?PHP ACLRole::toArray怎么用?PHP ACLRole::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACLRole
的用法示例。
在下文中一共展示了ACLRole::toArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$return = array('module' => 'ACLRoles', 'action' => 'index', 'record' => '');
if (!empty($_REQUEST['record'])) {
$role->retrieve($_REQUEST['record']);
$categories = ACLRole::getRoleActions($_REQUEST['record']);
$role_name = $role->name;
if (!empty($_REQUEST['isDuplicate'])) {
//role id is stripped here in duplicate so anything using role id after this will not have it
$role->id = '';
} else {
$return['record'] = $role->id;
$return['action'] = 'DetailView';
}
} else {
$categories = ACLRole::getRoleActions('');
}
$sugar_smarty->assign('ROLE', $role->toArray());
$tdwidth = 10;
if (isset($_REQUEST['return_module'])) {
$return['module'] = $_REQUEST['return_module'];
if (isset($_REQUEST['return_action'])) {
$return['action'] = $_REQUEST['return_action'];
}
if (isset($_REQUEST['return_record'])) {
$return['record'] = $_REQUEST['return_record'];
}
}
$sugar_smarty->assign('RETURN', $return);
$names = ACLAction::setupCategoriesMatrix($categories);
if (!empty($names)) {
$tdwidth = 100 / sizeof($names);
}
示例2: getAllRoles
/**
* static getAllRoles($returnAsArray = false)
*
* @param boolean $returnAsArray - should it return the results as an array of arrays or as an array of ACLRoles
*
* @return either an array of array representations of acl roles or an array of ACLRoles
*/
function getAllRoles($returnAsArray = false)
{
$db = DBManagerFactory::getInstance();
$query = "SELECT acl_roles.* FROM acl_roles\n WHERE acl_roles.deleted=0 ORDER BY name";
$result = $db->query($query);
$roles = [];
while ($row = $db->fetchByAssoc($result)) {
$role = new ACLRole();
$role->populateFromRow($row);
if ($returnAsArray) {
$roles[] = $role->toArray();
} else {
$roles[] = $role;
}
}
return $roles;
}
示例3: testtoArray
public function testtoArray()
{
$aclRole = new ACLRole();
//wihout any fields set
$expected = array('id' => '', 'name' => '', 'description' => '');
$actual = $aclRole->toArray();
$this->assertSame($expected, $actual);
//with fileds pre populated
$aclRole->id = '1';
$aclRole->name = 'test';
$aclRole->description = 'some description text';
$expected = array('id' => '1', 'name' => 'test', 'description' => 'some description text');
$actual = $aclRole->toArray();
$this->assertSame($expected, $actual);
}