public function getUserRoles($user, Content $content = null)
    {
        $userRoleNames = $user['roles'];
        if (!is_array($userRoleNames)) {
            throw new AccessControlException('Expected a user-like array, but the "roles" property is not an array');
        }
        $userRoleNames[] = self::ROLE_EVERYONE;
        if ($content && $content['user'] && $content['user']['id'] === $user['id']) {
            $userRoleNames[] = self::ROLE_OWNER;
        }
        $userRoleNames[] = self::ROLE_OWNER;

        $self = $this;

        return array_combine(
            $userRoleNames,
            array_map(
                function ($roleName) use ($self) {
                    return $self->getRole($roleName);
                },
                $userRoleNames
            )
        );
    }
public function getUserRoles($user, Content $content = null)
    {
        $userRoleNames = $user['roles'];
        if (!is_array($userRoleNames)) {
            throw new AccessControlException('Expected a user-like array, but the "roles" property is not an array');
        }
        $userRoleNames[] = self::ROLE_EVERYONE;
        if ($content && $content['user'] && $content['user']['id'] === $user['id']) {
            $userRoleNames[] = self::ROLE_OWNER;
        }
        $userRoleNames[] = self::ROLE_OWNER;

        $self = $this;

        return array_combine(
            $userRoleNames,
            array_map(
                function ($roleName) use ($self) {
                    return $self->getRole($roleName);
                },
                $userRoleNames
            )
        );
    }
public function getUserRoles ( $ user , Content $ content = null ) { $ userRoleNames = $ user [ 'roles' ] ; if ( ! is_array ( $ userRoleNames ) ) { throw new AccessControlException ( 'Expected a user-like array, but the "roles" property is not an array' ) ; } $ userRoleNames [ ] = self :: ROLE_EVERYONE ; if ( $ content && $ content [ 'user' ] && $ content [ 'user' ] [ 'id' ] === $ user [ 'id' ] ) { $ userRoleNames [ ] = self :: ROLE_OWNER ; } $ userRoleNames [ ] = self :: ROLE_OWNER ; $ self = $ this ; return array_combine ( $ userRoleNames , array_map ( function ( $ roleName ) use ( $ self ) { return $ self -> getRole ( $ roleName ) ; } , $ userRoleNames ) ) ; }
Gets the roles for a given user. If a content type is specified, the
"owner" role is added if appropriate.

@param array   $user    An array as returned by Users::getUser()
@param Content $content An optional Content object to check ownership

@throws AccessControlException

@return array An associative array of roles for the given user
Gets the roles for a given user . If a content type is specified the owner role is added if appropriate .