eZ\Publish\Core\REST\Server\Controller\User::loadUser PHP Method

loadUser() public method

Loads a user for the given ID.
public loadUser ( $userId ) : RestUser
$userId
return eZ\Publish\Core\REST\Server\Values\RestUser
    public function loadUser($userId)
    {
        $user = $this->userService->loadUser($userId);
        $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));
    }