private function collectPermissions(RoleInterface $role)
    {
        if (method_exists($role, 'getPermissions')) {
            $permissions = $role->getPermissions();
        } else {
            // Gather the permissions for the given role. We have to use reflection as
            // the RoleInterface does not have "getPermissions" method
            $reflectionProperty = new ReflectionProperty($role, 'permissions');
            $reflectionProperty->setAccessible(true);

            $permissions = $reflectionProperty->getValue($role);
        }

        if ($permissions instanceof Traversable) {
            $permissions = iterator_to_array($permissions);
        }

        array_walk($permissions, function (&$permission) {
            $permission = (string) $permission;
        });

        $this->collectedPermissions[$role->getName()] = array_values($permissions);
    }
private function collectPermissions(RoleInterface $role)
    {
        if (method_exists($role, 'getPermissions')) {
            $permissions = $role->getPermissions();
        } else {
            // Gather the permissions for the given role. We have to use reflection as
            // the RoleInterface does not have "getPermissions" method
            $reflectionProperty = new ReflectionProperty($role, 'permissions');
            $reflectionProperty->setAccessible(true);

            $permissions = $reflectionProperty->getValue($role);
        }

        if ($permissions instanceof Traversable) {
            $permissions = iterator_to_array($permissions);
        }

        array_walk($permissions, function (&$permission) {
            $permission = (string) $permission;
        });

        $this->collectedPermissions[$role->getName()] = array_values($permissions);
    }
private function collectPermissions ( RoleInterface $ role ) { if ( method_exists ( $ role , 'getPermissions' ) ) { $ permissions = $ role -> getPermissions ( ) ; } else { // Gather the permissions for the given role. We have to use reflection as // the RoleInterface does not have "getPermissions" method $ reflectionProperty = new ReflectionProperty ( $ role , 'permissions' ) ; $ reflectionProperty -> setAccessible ( true ) ; $ permissions = $ reflectionProperty -> getValue ( $ role ) ; } if ( $ permissions instanceof Traversable ) { $ permissions = iterator_to_array ( $ permissions ) ; } array_walk ( $ permissions , function ( & $ permission ) { $ permission = ( string ) $ permission ; } ) ; $ this -> collectedPermissions [ $ role -> getName ( ) ] = array_values ( $ permissions ) ; }
Collect permissions for the given role

@param  RoleInterface $role
@return void
Collect permissions for the given role