public function loadUser($userId)
    {
        $user = $this->userService->loadUser($userId, Language::ALL);

        $userContentInfo = $user->getVersionInfo()->getContentInfo();
        $contentType = $this->contentTypeService->loadContentType($userContentInfo->contentTypeId);

        try {
            $userMainLocation = $this->locationService->loadLocation($userContentInfo->mainLocationId);
            $relations = $this->contentService->loadRelations($user->getVersionInfo());
        } catch (UnauthorizedException $e) {
            // TODO: Hack for special case to allow current logged in user to load him/here self (but not relations)
            if ($user->id == $this->repository->getCurrentUser()->id) {
                $userMainLocation = $this->repository->sudo(
                    function () use ($userContentInfo) {
                        return $this->locationService->loadLocation($userContentInfo->mainLocationId);
                    }
                );
                // user may not have permissions to read related content, for security reasons do not use sudo().
                $relations = array();
            } else {
                throw $e;
            }
        }

        return new Values\CachedValue(
            new Values\RestUser(
                $user,
                $contentType,
                $userContentInfo,
                $userMainLocation,
                $relations
            ),
            array('locationId' => $userContentInfo->mainLocationId)
        );
    }
public function loadUser($userId)
    {
        $user = $this->userService->loadUser($userId, Language::ALL);

        $userContentInfo = $user->getVersionInfo()->getContentInfo();
        $contentType = $this->contentTypeService->loadContentType($userContentInfo->contentTypeId);

        try {
            $userMainLocation = $this->locationService->loadLocation($userContentInfo->mainLocationId);
            $relations = $this->contentService->loadRelations($user->getVersionInfo());
        } catch (UnauthorizedException $e) {
            // TODO: Hack for special case to allow current logged in user to load him/here self (but not relations)
            if ($user->id == $this->repository->getCurrentUser()->id) {
                $userMainLocation = $this->repository->sudo(
                    function () use ($userContentInfo) {
                        return $this->locationService->loadLocation($userContentInfo->mainLocationId);
                    }
                );
                // user may not have permissions to read related content, for security reasons do not use sudo().
                $relations = array();
            } else {
                throw $e;
            }
        }

        return new Values\CachedValue(
            new Values\RestUser(
                $user,
                $contentType,
                $userContentInfo,
                $userMainLocation,
                $relations
            ),
            array('locationId' => $userContentInfo->mainLocationId)
        );
    }
public function loadUser ( $ userId ) { $ user = $ this -> userService -> loadUser ( $ userId , Language :: ALL ) ; $ userContentInfo = $ user -> getVersionInfo ( ) -> getContentInfo ( ) ; $ contentType = $ this -> contentTypeService -> loadContentType ( $ userContentInfo -> contentTypeId ) ; try { $ userMainLocation = $ this -> locationService -> loadLocation ( $ userContentInfo -> mainLocationId ) ; $ relations = $ this -> contentService -> loadRelations ( $ user -> getVersionInfo ( ) ) ; } catch ( UnauthorizedException $ e ) { // TODO: Hack for special case to allow current logged in user to load him/here self (but not relations) if ( $ user -> id == $ this -> repository -> getCurrentUser ( ) -> id ) { $ userMainLocation = $ this -> repository -> sudo ( function ( ) use ( $ userContentInfo ) { return $ this -> locationService -> loadLocation ( $ userContentInfo -> mainLocationId ) ; } ) ; // user may not have permissions to read related content, for security reasons do not use sudo(). $ relations = array ( ) ; } else { throw $ e ; } } return new Values \ CachedValue ( new Values \ RestUser ( $ user , $ contentType , $ userContentInfo , $ userMainLocation , $ relations ) , array ( 'locationId' => $ userContentInfo -> mainLocationId ) ) ; }
Loads a user for the given ID.

@param $userId

@return \eZ\Publish\Core\REST\Server\Values\RestUser
Loads a user for the given ID .