/** * HttpXpressengineException constructor. * * @param array $args arguments array * @param int $statusCode exception status code * @param \Exception|null $previous exception * @param array $headers header * @param int $code code */ public function __construct($args = [], $statusCode = null, \Exception $previous = null, array $headers = [], $code = 0) { if ($statusCode !== null) { $this->statusCode = $statusCode; } $this->headers = $headers; parent::__construct($args, $code, $previous); }
private function connectToUser($user, $userInfo) { $handler = app('xe.user'); // retrieve account and email $existingAccount = $handler->accounts()->where(['provider' => $this->provider, 'accountId' => $userInfo->id])->first(); if (data_get($userInfo, 'email', false)) { $existingEmail = $handler->emails()->findByAddress($userInfo->email); } else { $existingEmail = null; } $id = $user->getId(); if ($existingAccount !== null && $existingAccount->userId !== $id) { $e = new XpressengineException(); $e->setMessage('이미 다른 회원에 의해 등록된 계정입니다.'); throw $e; } if ($existingEmail !== null && $existingEmail->userId !== $id) { $e = new XpressengineException(); $e->setMessage('이미 다른 회원에 의해 등록된 이메일입니다.'); throw $e; } $userData = $this->resolveUserInfo($userInfo); XeDB::beginTransaction(); try { if ($existingAccount === null) { $accountData = $this->resolveAccountInfo($userInfo); $existingAccount = $handler->accounts()->create($user, $accountData); } if ($existingEmail === null) { $existingEmail = $handler->emails()->create($user, ['address' => $userData['email']]); } } catch (\Exception $e) { XeDB::rollback(); throw $e; } XeDB::commit(); }
/** * 생성자에서는 message 대신 message를 생성시 필요한 argument 목록을 입력받는다. * Message 는 \Xpressengine\Translation\Translator 로 변환되어 처리된다. * * Message 변환은 \App\Exceptions\Handler 에 서 처리된다. * * @param array $args message 변환 시 사용될 argument 목록 * @param int $code The Exception code. * @param Exception $previous The previous exception used for the exception chaining. Since 5.3.0 */ public function __construct(array $args = [], $code = 0, Exception $previous = null) { $this->args = $args; $this->message .= ' for ' . $args['id']; parent::__construct($args, $code, $previous); }