Add child role to role
@param Role $parentRole
@param Role $childRole
@throws CyclicException
@throws DatabaseException
@throws NotUniqueException
@throws \Doctrine\ORM\Query\QueryException
342279
public function addChildRole(Role $parentRole, Role $childRole)
    {
        $roleHierarchy = new RoleHierarchy();

        $roleHierarchy->setParentRole($parentRole);
        $roleHierarchy->setChildRole($childRole);

        $this->checkForCyclicHierarchy($childRole->getId(), $parentRole->getId());

        try {
            $this->saveEntity($roleHierarchy);
        }  catch (UniqueConstraintViolationException $e) {
            throw new NotUniqueException('Child role ' . $childRole->getName() . ' is already has parent role ' . $parentRole->getName());
        }
    }
4206
public function addRoleForUser($userId, $roleName)
    {
        $roleIdExpression = new Expression(
            '(SELECT `id` from `user_roles` WHERE `name` = ?)',
            $roleName
        );

        $query = $this->getSqlObject()
            ->insert()
            ->values([
                'user_id' => $userId,
                'role_id' => $roleIdExpression,
            ]);

        $this->execute($query);
    }
73897
public function addGroupesRole(\Thibautg16\UtilisateurBundle\Entity\Groupe $groupesRole)
    {
        $this->groupes_role[] = $groupesRole;

        return $this;
    }
20322
public function attachRole($role, $reload = true)
    {
        if ($this->hasRole($role)) return;

        event(new AttachingRoleToUser($this, $role));
        $this->roles()->attach($role);
        event(new AttachedRoleToUser($this, $role));

        $this->loadRoles($reload);
    }
1221673
public function addRole($role)
    {
        if (!$this->hasRole($role)) {
            $this->roles[] = strtoupper($role);
        }

        return $this;
    }
696813
protected function insertRoles(array $roles)
    {
        foreach ($roles as $role) {
            if (null === $role->getParent()) {
                $this->addRole($role);
            } else {
                $parents   = [];
                $parents[] = $role->getParent()->getRoleId();
                $this->addRole($role, $parents);
            }
        }

        return $this;
    }
72870
public function addRole(string $role): PermissionManager
    {
        if ($this->hasRole($role)) {
            throw new RoleException("Role '{$role}' already exists");
        }

        $this->permissions[$role] = [
            //No associated permissions
        ];

        return $this;
    }
430385
private function saveRole ($roleForm)
		{

			$auth = Yii::$app->getAuthManager();
			$role = $auth->createRole($roleForm->name);
			$role->type = Role::TYPE_ROLE;
			$role->description = $roleForm->description;
			if (!empty($roleForm->ruleName))
				$role->ruleName = $roleForm->ruleName;
			$role->data = $roleForm->data;

			if ($roleForm->method == 'rbac-add')
				$auth->add($role);
			else
			{
				$auth->update($roleForm->method, $role);
				$auth->removeChildren($role);
			}

			if (is_array($roleForm->childRoles) and count($roleForm->childRoles) > 0)
				foreach ($roleForm->childRoles as $childRole)
				{
					$child = $auth->getRole($childRole);
					$auth->addChild($role, $child);
				}

			if (is_array($roleForm->childPermissions) and count($roleForm->childPermissions) > 0)
				foreach ($roleForm->childPermissions as $childPermission)
				{
					$child = $auth->getPermission($childPermission);
					$auth->addChild($role, $child);
				}
		}
103738
public function setActiveRole(\WobbleCode\UserBundle\Document\Role $activeRole)
    {
        $this->activeRole = $activeRole;
        return $this;
    }
664604
public function addRole(string ...$role)
    {
        foreach ($role as $_role)
        {
            $this->roleRegistry->save($_role);
        }
    }
61739
public function addRoleToToolAction(AdminTool $tool, Role $role)
    {
        $this->toolManager->addRoleToAdminTool($tool, $role);

        return new Response('success');
    }
901868
public function addChild(LeafRole $child)
    {
        $this->children->add($child);
        $child->setParent($this);

        return $this;
    }
1252048
public function hasChildRoleId($parentRoleId, $findingChildId)
    {
        $childIds = $this->getChildIds([$parentRoleId]);

        if (count($childIds) > 0) {

            if (in_array($findingChildId, $childIds))
                return true;

            foreach ($childIds as $childId) {

                if ($this->hasChildRoleId($childId, $findingChildId) == true) {
                    return true;
                }

            }
        }

        return false;
    }
228437
private function validateAddingChildren(NodeInterface $parentNode)
	{
		$allow = true;
		
		/*
		 * FIXME: These checks are not good, but we can receive NodeAbstraction
		 * or other NodeInterface with magic __call as well..
		 */
		if ($parentNode instanceof NodeAbstraction) {
			if ($parentNode->leafInterface) {
				$allow = false;
			}
		}
		
		if ($parentNode instanceof NodeLeafInterface) {
			$allow = false;
		}
		
		if ( ! $allow) {
			$parentDump = static::dump($parentNode);
			throw new Exception\InvalidOperation("Children cannot added to the NodeLeafInterface object {$parentDump}");
		}
	}
39604
public function addRole($id, $role)
    {
        if (empty($role) || !$user = $this->getUser($id)) {
            return false;
        }

        // Add the role to the $user['roles'] array
        $user['roles'][] = $role;

        return $this->saveUser($user);
    }
320790
protected function addUserRole()
    {
        $this->controlAccess('user_role_add');

        if ($this->role->add($this->getSubmitted())) {
            $this->redirect('admin/user/role', $this->text('Role has been added'), 'success');
        }

        $this->redirect('', $this->text('Role has not been added'), 'warning');
    }
67131
public function attachRole($role)
    {
        if (! $this->hasRole($role->name)) {
            $this->roles()->attach($role);
        }
    }