private function collectIdentityRolesAndPermissions(RoleService $roleService)
    {
        $identityRoles = $roleService->getIdentityRoles();

        foreach ($identityRoles as $role) {
            $roleName = $role->getName();

            if (!$role instanceof HierarchicalRoleInterface) {
                $this->collectedRoles[] = $roleName;
            } else {
                $iteratorIterator = new RecursiveIteratorIterator(
                    new RecursiveRoleIterator($role->getChildren()),
                    RecursiveIteratorIterator::SELF_FIRST
                );

                foreach ($iteratorIterator as $childRole) {
                    $this->collectedRoles[$roleName][] = $childRole->getName();
                    $this->collectPermissions($childRole);
                }
            }

            $this->collectPermissions($role);
        }
    }
private function collectIdentityRolesAndPermissions(RoleService $roleService)
    {
        $identityRoles = $roleService->getIdentityRoles();

        foreach ($identityRoles as $role) {
            $roleName = $role->getName();

            if (!$role instanceof HierarchicalRoleInterface) {
                $this->collectedRoles[] = $roleName;
            } else {
                $iteratorIterator = new RecursiveIteratorIterator(
                    new RecursiveRoleIterator($role->getChildren()),
                    RecursiveIteratorIterator::SELF_FIRST
                );

                foreach ($iteratorIterator as $childRole) {
                    $this->collectedRoles[$roleName][] = $childRole->getName();
                    $this->collectPermissions($childRole);
                }
            }

            $this->collectPermissions($role);
        }
    }
private function collectIdentityRolesAndPermissions ( RoleService $ roleService ) { $ identityRoles = $ roleService -> getIdentityRoles ( ) ; foreach ( $ identityRoles as $ role ) { $ roleName = $ role -> getName ( ) ; if ( ! $ role instanceof HierarchicalRoleInterface ) { $ this -> collectedRoles [ ] = $ roleName ; } else { $ iteratorIterator = new RecursiveIteratorIterator ( new RecursiveRoleIterator ( $ role -> getChildren ( ) ) , RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ iteratorIterator as $ childRole ) { $ this -> collectedRoles [ $ roleName ] [ ] = $ childRole -> getName ( ) ; $ this -> collectPermissions ( $ childRole ) ; } } $ this -> collectPermissions ( $ role ) ; } }
Collect roles and permissions

@param  RoleService $roleService
@return void
Collect roles and permissions