本文整理汇总了PHP中Role::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::getName方法的具体用法?PHP Role::getName怎么用?PHP Role::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role::getName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setParent
/**
* Set the parent role
*
* @param Role $parent
* @return Role
*/
public function setParent(Role $parent)
{
if ($parent->getName() !== $this->getName()) {
$this->parent = $parent;
$this->parent->addChild($this);
}
return $this;
}
示例2: fill
/**
* {@inheritdoc}
* @param \Role $role
*/
public function fill($form, $role)
{
$form->get('name')->setData($role->getName());
$form->get('display_as_leader')->setData($role->displayAsLeader());
$form->get('display_icon')->setData($role->getDisplayIcon());
$form->get('display_color')->setData($role->getDisplayColor());
$form->get('display_name')->setData($role->getDisplayName());
$form->get('display_order')->setData($role->getDisplayOrder());
$form->get('permissions')->setData($role->getPermObjects());
}
示例3: isAllowed
/**
* Check owing Role & Resource and match its with $roleName & $resourceName;
* if match was found depending on action allow or deny access to $resourceName for $roleName.
*
* @param string $needRuleName
* @param string $needRoleName
* @param string $needResourceName
*
* @return RuleResult|null null is returned if there is no matched Role & Resource in this rule.
* RuleResult otherwise.
*/
public function isAllowed($needRuleName, $needRoleName, $needResourceName)
{
static $roleCache = array();
static $resourceCache = array();
if ($needRuleName != 'RuleWide' && $this->name === $needRuleName || $this->isRuleMatched($needRuleName)) {
if (null !== $this->role) {
$roleNameTmp = $this->role->getName();
if (!isset($roleCache[$roleNameTmp])) {
$roles = iterator_to_array($this->role);
$roleCache[$roleNameTmp] = $roles;
} else {
$roles = $roleCache[$roleNameTmp];
}
} else {
$roles = array(null);
}
if (null !== $this->resource) {
$resourceNameTmp = $this->resource->getName();
if (!isset($resourceCache[$resourceNameTmp])) {
$resources = iterator_to_array($this->resource);
$resourceCache[$resourceNameTmp] = $resources;
} else {
$resources = $resourceCache[$resourceNameTmp];
}
} else {
$resources = array(null);
}
foreach ($roles as $role) {
if (null === $role || $role && $role->name === $needRoleName) {
$roleNameMatched = true;
} else {
$roleNameMatched = false;
}
foreach ($resources as $resource) {
if (null === $resource || $resource && $resource->name === $needResourceName) {
$resourceNameMatched = true;
} else {
$resourceNameMatched = false;
}
// Check if $role and $resource match to need role and resource.
$ruleResult = null;
if ($roleNameMatched === true && $resourceNameMatched === true) {
$ruleResult = new RuleResult($this, $needRoleName, $needResourceName);
}
if ($ruleResult) {
return $ruleResult;
}
}
}
}
return null;
}
示例4: testCreateRoleWithProjectReference
public function testCreateRoleWithProjectReference()
{
$xml = simplexml_load_file($this->roleProjectFile);
$expectedId = 'RELATED_PROJECT';
$expectedUrl = 'http://example.com/youtrack/rest/admin/project/' . $expectedId;
$role = new Role($xml);
$this->assertEquals('Developer', $role->getName());
$this->assertNotEmpty($role->getProjectRefs());
$this->assertCount(1, $role->getProjectRefs());
$refs = $role->getProjectRefs();
$ref0 = $refs[0];
$this->assertEquals($expectedId, $ref0->getId());
$this->assertEquals($expectedUrl, $ref0->getUrl());
}
示例5: testNormalRole
public function testNormalRole()
{
$role = new Role($this->normalRole->getId());
$this->player_b->addRole($role->getId());
$this->assertFalse($role->displayAsLeader());
$this->assertFalse($role->isProtected());
$this->assertEquals("Sample Normal Role", $role->getName());
$this->assertNull($role->getDisplayIcon());
$this->assertNull($role->getDisplayColor());
$this->assertEquals("Sample Normal Role", $role->getDisplayName());
$this->assertEquals(-1, $role->getDisplayOrder());
$this->assertArrayContainsModel($role, Role::getRoles($this->player_b->getId()));
$this->wipe($role);
}
示例6: array
/**
* Set specific role as default role
*
* @param void
* @return null
*/
function set_as_default()
{
if ($this->request->isSubmitted()) {
if ($this->active_role->isNew()) {
$this->httpError(HTTP_ERR_NOT_FOUND);
}
// if
if ($this->active_role->getType() == ROLE_TYPE_PROJECT) {
$this->httpError(HTTP_ERR_INVALID_PROPERTIES);
}
// if
ConfigOptions::setValue('default_role', $this->active_role->getId());
flash_success(':name role has been set as default', array('name' => $this->active_role->getName()));
$this->redirectTo('admin_roles');
} else {
$this->httpError(HTTP_ERR_BAD_REQUEST);
}
// if
}
示例7: getName
public function getName()
{
$this->_load();
return parent::getName();
}
示例8: getName
/**
* Return display name property. (readonly)
*
* @author KnowledgeTree Team
* @access public
* @return string
*/
public function getName()
{
return $this->role->getName();
}
示例9: deleteRole
public function deleteRole(Role $roleToDelete)
{
// check permissions
if (!PermissionEngine::getInstance()->currentUserCanDo('userCanDeleteRoles')) {
return false;
}
$db = Database::getInstance();
if (!$db->isConnected()) {
return false;
}
$roleID = $db->escapeString($roleToDelete->getID());
$roleName = $db->escapeString($roleToDelete->getName());
$results = $db->removeData('role', 'roleID = ' . $roleID . ' AND roleName = \'' . $roleName . '\'');
if (!$results) {
return false;
}
return true;
}
示例10: has
/**
* @param Role|string $role
*
* @throws \InvalidArgumentException
*
* @return bool
*/
public function has($role)
{
if (is_scalar($role)) {
$role = new Role($role);
} elseif (!$role instanceof Role) {
throw new \InvalidArgumentException('$role is expected to be of type string or Gobline\\Acl\\Role');
}
$roleName = $role->getName();
return isset($this->roles[$roleName]);
}
示例11: CompareNoRef
/**
* TODO: Enter description here ...
* @param Role $a
* @param Role $b
* @return number
*/
function CompareNoRef($a, $b)
{
$ap = $a->getHomeProject();
$bp = $b->getHomeProject();
if ($ap == NULL && $bp != NULL) {
return 1;
} elseif ($ap != NULL && $bp == NULL) {
return -1;
} elseif ($ap == NULL && $bp == NULL) {
$tmp = strcoll($a->getName(), $b->getName());
return $tmp;
} else {
$projcmp = new ProjectComparator();
$projcmp->criterion = 'name';
$tmp = $projcmp->Compare($ap, $bp);
if ($tmp) {
/* Different projects, sort accordingly */
return $tmp;
}
return strcoll($a->getName(), $b->getName());
}
}
示例12: addRole
/**
* 添加一个角色,如果角色名已经存在,则替换老值
* @param Role $role
* @return \tfc\auth\Authoriz
*/
public function addRole(Role $role)
{
$name = $role->getName();
$this->_roles[$name] = $role;
return $this;
}
示例13: testGetName
public function testGetName()
{
$role = new Role('admin');
$this->assertEquals('admin', $role->getName());
}