本文整理汇总了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());
}
}
示例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');
}
示例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']);
}
示例4: required
public static function required($available = false, $function)
{
if ($available === false) {
Response::error('Missing parameters. Can not execute function ' . $function);
}
return true;
}
示例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")));
}
}
示例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('/');
}
}
示例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');
}
示例8: handle
public function handle($request, Closure $next)
{
if (!Request::ajax()) {
return Response::error('404');
}
return $next($request);
}
示例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). ');
}
}
示例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;
}
示例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');
}
}
}
示例12: mkdir
/**
* @param $dir
*/
static function mkdir($dir)
{
if (!is_dir($dir)) {
if (!mkdir($dir, 0777, true)) {
Response::error('Failed to create dir:' . $dir);
}
}
}
示例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);
}
}
示例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));
}
示例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));
}
}