Author: XE Developers (developers@xpressengine.com)
Inheritance: extends XpressengineException, implements Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
Exemplo n.º 1
0
 /**
  * Validate the given request with the given rules.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  array  $rules
  * @param  array  $messages
  * @param  array  $customAttributes
  * @return void
  * @throws HttpXpressengineException
  */
 public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
 {
     $validator = Validator::make($request->all(), $rules, $messages, $customAttributes);
     if ($validator->fails()) {
         $request->flash();
         $e = new HttpXpressengineException(Response::HTTP_NOT_ACCEPTABLE);
         $e->setMessage($validator->errors()->first());
         throw $e;
     }
 }
 public function postUpdatePlugin($pluginId)
 {
     try {
         Plugin::updatePlugin($pluginId);
     } catch (XpressengineException $e) {
         $exception = new HttpXpressengineException(Response::HTTP_FORBIDDEN);
         $exception->setMessage($e->getMessage());
         throw $exception;
     } catch (\Exception $e) {
         throw $e;
     }
     return Redirect::route('settings.plugins')->withAlert(['type' => 'success', 'message' => '플러그인을 업데이트했습니다.']);
 }
Exemplo n.º 3
0
 /**
  * exception filter
  *
  * @param \Exception $e exception
  *
  * @return \Exception
  */
 private function filter(Exception $e)
 {
     $responseException = null;
     /*
      * make responseException
      */
     // token mismatch
     if ($e instanceof TokenMismatchException) {
         $responseException = new HttpXpressengineException(Response::HTTP_FORBIDDEN);
         $responseException->setMessage(xe_trans('xe::tokenMismatch'));
     } elseif ($e instanceof NotFoundHttpException) {
         $responseException = new HttpXpressengineException(Response::HTTP_NOT_FOUND);
         $responseException->setMessage(xe_trans('xe::pageNotFound'));
     } elseif ($e instanceof AccessDeniedHttpException) {
         // Redirect is not returned(redirection is not executed). only set current uri to session
         $e->setMessage(xe_trans('xe::accessDenied'));
         $responseException = $e;
     } elseif ($e instanceof HttpExceptionInterface) {
         // 인터페이스가...
         $e->setMessage(xe_trans($e->getMessage(), $e->getArgs()));
         $responseException = $e;
     } elseif ($e instanceof XpressengineException) {
         // plugin cache 삭제
         if ($e instanceof PluginFileNotFoundException) {
             $cache = app('cache');
             Event::fire('cache:clearing', ['plugins']);
             $cache->store('plugins')->flush();
             Event::fire('cache:cleared', ['plugins']);
         }
         $responseException = new HttpXpressengineException(Response::HTTP_INTERNAL_SERVER_ERROR);
         $message = xe_trans($e->getMessage(), $e->getArgs());
         if ('' === $message) {
             $message = get_class($e);
         } elseif ($message == $e->getMessage()) {
             $message = $e->getMessage();
         }
         $responseException->setMessage($message);
     } elseif ($e instanceof ModelNotFoundException) {
         $responseException = new NotFoundHttpException($e->getMessage(), $e);
     } else {
         $responseException = new HttpXpressengineException(Response::HTTP_INTERNAL_SERVER_ERROR);
         $responseException->setMessage(xe_trans('xe::systemError'));
     }
     if ($responseException->getMessage() == '') {
         $responseException->setMessage(xe_trans('xe::systemError'));
     }
     return $responseException;
 }
Exemplo n.º 4
0
 protected function checkCaptcha($action)
 {
     $action = $action === 'login' ? 'common' : $action;
     $config = app('xe.config')->get('member.' . $action);
     if ($config->get('useCaptcha', false) === true) {
         if (app('xe.captcha')->verify() !== true) {
             $e = new HttpXpressengineException(403);
             $e->setMessage('자동인증방지 기능을 통과하지 못하였습니다.');
             throw $e;
         }
     }
 }