当前位置: 首页>>代码示例>>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;未经允许,请勿转载。