當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Response::error方法代碼示例

本文整理匯總了PHP中Response::error方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::error方法的具體用法?PHP Response::error怎麽用?PHP Response::error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Response的用法示例。


在下文中一共展示了Response::error方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * Executes a request.
  *
  * @param request Request to execute.
  *
  * @return Response Response to send.
  */
 public function execute(Request $request)
 {
     try {
         $segments = $request->getPathSegments();
         if (count($segments) > 0) {
             $firstSegment = $segments[0];
             if (array_key_exists($firstSegment, $this->controllers)) {
                 $controller = $this->controllers[$firstSegment];
                 $controllerRequest = $request->consume();
                 $resource = $controller->getResource($controllerRequest);
                 if (isset($resource)) {
                     $verb = $request->getVerb();
                     if (method_exists($resource, $verb)) {
                         return $resource->{$verb}($controllerRequest);
                     } else {
                         return Response::notSupported();
                     }
                 }
             }
         }
         return Response::notFound();
     } catch (\Exception $e) {
         return Response::error($e->getMessage());
     }
 }
開發者ID:andresrc,項目名稱:tcus-php-as,代碼行數:32,代碼來源:MVC.php

示例2: get_remove_from_favorites

 public function get_remove_from_favorites($page_id)
 {
     if (Favorite::remove($page_id)) {
         return Redirect::to("page/{$page_id}")->with('removed', true);
     }
     return Response::error('500');
 }
開發者ID:bankorh,項目名稱:ecom1_laravel,代碼行數:7,代碼來源:content.php

示例3: testErrorMethodSetsContentToErrorView

 /**
  * Test the Response::error method.
  *
  * @group laravel
  */
 public function testErrorMethodSetsContentToErrorView()
 {
     $response = Response::error('404', array('name' => 'Taylor'));
     $this->assertEquals(404, $response->status());
     $this->assertEquals('error.404', $response->content->view);
     $this->assertEquals('Taylor', $response->content->data['name']);
 }
開發者ID:gilyaev,項目名稱:framework-bench,代碼行數:12,代碼來源:response.test.php

示例4: required

 public static function required($available = false, $function)
 {
     if ($available === false) {
         Response::error('Missing parameters. Can not execute function ' . $function);
     }
     return true;
 }
開發者ID:windhamdavid,項目名稱:Lychee,代碼行數:7,代碼來源:Validator.php

示例5: actionCreateClient

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreateClient()
 {
     $hU = new HttpUtils();
     if ($hU->isAjaxRequest() == false) {
         Response::error("not allowed ;)");
     }
     if (isset($_POST["clientName"]) == false || isset($_POST["clientEmail"]) == false) {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_FALLA, "detalle" => "Faltan parámetros obligatorios")));
     }
     $cl = Cliente::model()->findAll("email=:email", array(':email' => $_POST["clientEmail"]));
     if (sizeof($cl) > 0) {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_FALLA, "detalle" => "Cliente {$_POST["clientEmail"]} ya registrado en el sistema")));
     }
     $cl = new Cliente();
     $cl->surname = "";
     $cl->comments = "";
     $cl->streetaddress = "";
     $cl->name = $_POST["clientName"];
     $cl->email = $_POST["clientEmail"];
     if ($cl->save()) {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_EXITO, "detalle" => "Cliente {$cl->email} registrado con éxito")));
     } else {
         Response::ok(CJSON::encode(array("resultado" => Constants::RESULTADO_OPERACION_FALLA, "detalle" => "Error registrando cliente {$cl->email} en el sistema")));
     }
 }
開發者ID:MRodriguez08,項目名稱:yii-bundles-app,代碼行數:29,代碼來源:NotificationController.php

示例6: action_edit

 public function action_edit($id)
 {
     if (Auth::check() && Session::has('id')) {
         $account = Account::find(Session::get('id'));
         $location = Location::find($id);
         if (Input::has('address') && Input::has('city') && Input::has('postal_code')) {
             if ($account->id == $location->account_id) {
                 Input::has('address') ? $location->address = strip_tags(Input::get('address')) : ($location->address = '');
                 Input::has('city') ? $location->city = strip_tags(Input::get('city')) : ($location->city = '');
                 Input::has('postal_code') ? $location->postal_code = strip_tags(Input::get('postal_code')) : ($location->postal_code = '');
                 $location->save();
                 return Redirect::to("/account/myLocations");
             } else {
                 return Redirect::to("/account/myLocations");
             }
         } else {
             if ($location->account_id == $account->id) {
                 $locations = Location::all();
                 $view = View::make('location.edit.index')->with('title', 'Edit Location')->with('location', $location)->with('locations', $locations);
                 return $view;
             } else {
                 return Response::error('403');
             }
         }
     } else {
         return Redirect::to('/');
     }
 }
開發者ID:angmark0309,項目名稱:remarket,代碼行數:28,代碼來源:location.php

示例7: page

 public function page($slug = '')
 {
     // allow admin to view unpublished posts
     if (Users::authed() === false) {
         $params['status'] = 'published';
     }
     // if no slug is set we will use our default page
     if (empty($slug)) {
         $params['id'] = Config::get('metadata.home_page');
     } else {
         $params['slug'] = $slug;
     }
     // if we cant find either it looks like we're barney rubble (in trouble)
     if (($page = Pages::find($params)) === false) {
         return Response::error(404);
     }
     // store our page for template functions
     IoC::instance('page', $page, true);
     // does the current page host our posts?
     if ($page->id == Config::get('metadata.posts_page')) {
         // render our posts template
         return Template::render('posts');
     }
     // render our page template
     Template::render('page');
 }
開發者ID:rubenvincenten,項目名稱:anchor-site,代碼行數:26,代碼來源:routes.php

示例8: handle

 public function handle($request, Closure $next)
 {
     if (!Request::ajax()) {
         return Response::error('404');
     }
     return $next($request);
 }
開發者ID:donotgowiththeflow,項目名稱:laravel-acl-seeinfront,代碼行數:7,代碼來源:Ajax.php

示例9: verifyOrgAccess

function verifyOrgAccess($orgName)
{
    global $dataporten;
    if (strcasecmp($orgName, $dataporten->getUserOrg()) !== 0) {
        Response::error(401, $_SERVER["SERVER_PROTOCOL"] . ' 401 Unauthorized (request mismatch org/user). ');
    }
}
開發者ID:skrodal,項目名稱:ac-csv-import-api,代碼行數:7,代碼來源:index.php

示例10: get

 /**
  * Method that returns current response array.
  * @return array 
  */
 public static function get()
 {
     if (empty(self::$response)) {
         Response::error(ErrorCodes::EMPTY_RESPONSE);
     }
     return self::$response;
 }
開發者ID:rosko,項目名稱:backvendor,代碼行數:11,代碼來源:Response.php

示例11: render

 public function render($slug = null, $check_restrictions = true)
 {
     if ($slug == null) {
         $slug = $this->page_slug;
     }
     if ($slug == '/' or empty($slug)) {
         $slug = 'home';
     }
     if ($slug == '404') {
         //page not found. Do we have a 404 page? really? :)
         $page = Model\Page::where('slug', '=', '404')->first();
         if (isset($page) and count($page) > 0) {
             $this->data['meta_title'] = $page->title;
             $this->data['meta_description'] = $page->meta_description;
             $this->data['meta_keywords'] = $page->meta_keywords;
             $this->data['page_content'] = $page->body;
             return $this->theme->render('pages::frontend.page', $this->data);
         } else {
             // How embarrassing we dont have a 404 page :)
             // Return default framework 404
             return Response::error('404');
         }
     }
     $page = Model\Page::where('slug', '=', $slug)->first();
     if (!isset($page) or empty($page)) {
         $page = Model\Page::where('slug', '=', '404')->first();
     }
     $page_access = explode(',', $page->restricted_to);
     if (Restriction::passes($page_access, new Auth())) {
         if (isset($page) and count($page) > 0) {
             $this->data['meta_title'] = $page->title;
             $this->data['meta_description'] = $page->meta_description;
             $this->data['meta_keywords'] = $page->meta_keywords;
             $this->data['page_content'] = $page->body;
             return $this->theme->render('pages::frontend.page', $this->data);
         } else {
             //page not found. Do we have a 404 page? really? :)
             $page = Model\Page::where('slug', '=', '404')->first();
             if (isset($page) and count($page) > 0) {
                 return Redirect::to('404');
             } else {
                 // How embarrassing we dont have a 404 page :)
                 // Return default framework 404
                 return Response::error('404');
             }
         }
     } else {
         // not allowed to view page
         //page not found. Do we have a 404 page? really? :)
         $page = Model\Page::where('slug', '=', '404')->first();
         if (isset($page) and count($page) > 0) {
             return Redirect::to('404');
         } else {
             // How embarrassing we dont have a 404 page :)
             // Return default framework 404
             return Response::error('404');
         }
     }
 }
開發者ID:juaniiie,項目名稱:mwi,代碼行數:59,代碼來源:Page.php

示例12: mkdir

 /**
  * @param $dir
  */
 static function mkdir($dir)
 {
     if (!is_dir($dir)) {
         if (!mkdir($dir, 0777, true)) {
             Response::error('Failed to create dir:' . $dir);
         }
     }
 }
開發者ID:hilojack,項目名稱:php-lib,代碼行數:11,代碼來源:file.php

示例13: doAction

 /**
  * @brief doAction 請求分發處理
  *
  * @param $params 傳入參數
  *
  * @return void
  */
 public function doAction($params)
 {
     if (method_exists($this, $params['do'] . 'Do')) {
         $this->{$params['do'] . 'Do'}();
     } else {
         Response::error(404);
     }
 }
開發者ID:ZJU-Shaonian-Biancheng-Tuan,項目名稱:logx,代碼行數:15,代碼來源:ActionWidget.php

示例14: action_view

 public function action_view($slug = '')
 {
     $post = Post::where_slug($slug)->first();
     if (!$post) {
         return Response::error('404');
     }
     return $this->layout->nest('content', 'blog::post', array('post' => $post));
 }
開發者ID:SerdarSanri,項目名稱:Blog,代碼行數:8,代碼來源:post.php

示例15: get_index

 public function get_index()
 {
     $user = Auth::user();
     if (!$user) {
         return Response::error('404');
     } else {
         $this->layout->nest('content', 'user.account', array('user' => $user));
     }
 }
開發者ID:netcon-source,項目名稱:clementia,代碼行數:9,代碼來源:user.php


注:本文中的Response::error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。