checkMandatoryFields($command); /** @var UserRepositoryInterface $userRepository */ $userRepository = $this->getContainer()->get('domain.users.repository'); $user = $userRepository->getById((int)$command->getField('id')); if (!$user instanceof AbstractUser) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not retrieve user'); return $result; } if (!$this->getContainer()->getPermissionsService()->currentUserCanRead($user->getType())) { throw new AccessDeniedException('You are not allowed to read user'); } $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully retrieved user'); $result->setData([ Entities::USER => $user->toArray() ]); return $result; } }