本文整理汇总了PHP中Response::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::factory方法的具体用法?PHP Response::factory怎么用?PHP Response::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(Request $request)
{
if ($this->callback_depth() > $this->max_callback_depth()) {
throw new Request_Client_Recursion_Exception("Could not execute request to :uri - too many recursions after :depth requests", array(":uri" => $request->uri(), ":depth" => $this->callback_depth() - 1));
}
$orig_response = $response = Response::factory(array("_protocol" => $request->protocol()));
if (($cache = $this->cache()) instanceof HTTP_Cache) {
return $cache->execute($this, $request, $response);
}
$response = $this->execute_request($request, $response);
foreach ($this->header_callbacks() as $header => $callback) {
if ($response->headers($header)) {
$cb_result = call_user_func($callback, $request, $response, $this);
if ($cb_result instanceof Request) {
$this->assign_client_properties($cb_result->client());
$cb_result->client()->callback_depth($this->callback_depth() + 1);
$response = $cb_result->execute();
} elseif ($cb_result instanceof Response) {
$response = $cb_result;
}
if ($response !== $orig_response) {
break;
}
}
}
return $response;
}
示例2: get_response
public function get_response()
{
$view = View::factory('error/500');
$view->message = $this->getMessage();
$response = Response::factory()->status(500)->body($view->render());
return $response;
}
示例3: get_response
public function get_response()
{
$twig = Twig::factory('frontend/main');
$response = $twig->render('Public/404');
$response = Response::factory()->status(404)->body($response);
return $response;
}
示例4: response
/**
* Attempt to query error/500 manually, as we cannot catch exceptions through traditional HMVC requests.
* Catch potential exceptions such as database is down and display a lightweight error message.
*
* @param Exception $e
* @return Response
*/
public static function response(Exception $e)
{
if (Kohana::$environment >= Kohana::DEVELOPMENT) {
return parent::response($e);
}
try {
// Create the request, we need to set controller and action manual as they
// otherwise gets set in execute method.
$request = Request::factory();
$request->controller(Kohana_Exception::$_controller);
$request->action(Kohana_Exception::$_method);
// Setup the response object
$response = Response::factory();
$response->status(500);
$response->headers('Content-Type', Kohana_Exception::$error_view_content_type . '; charset=' . Kohana::$charset);
// Call the controller.
$controller = new Controller_Error($request, $response);
return $controller->execute();
} catch (Exception $e) {
// Render the fallback view.
$view = View::factory('errors/fallback');
$response = Response::factory();
$response->status(500);
$response->body($view->render());
return $response;
}
}
示例5: get_response
public function get_response()
{
$response = Response::factory();
$view = View::factory('errors/403');
$response->body($view->render());
return $response;
}
示例6: get_response
public function get_response()
{
// HTTP/404.php - это файл шаблона, можно указать другой файл
$view = View::factory('HTTP/404');
$view->message = $this->getMessage();
$response = Response::factory()->status(404)->body($view->render());
return $response;
}
示例7: get_response
/**
* Generate a Response for the 404 Exception.
*
* The user should be shown a nice 404 page.
*
* @return Response
*/
public function get_response()
{
$view = View::factory('errors/404');
// Remembering that `$this` is an instance of HTTP_Exception_404
$view->message = $this->getMessage();
$response = Response::factory()->status(404)->body($view->render());
return $response;
}
示例8: get_response
public function get_response()
{
$view = new View_Error_404();
$renderer = Kostache_Layout::factory('404');
$response = Response::factory()->status(404);
$response->body($renderer->render($view));
return $response;
}
示例9: get_response
/**
* Generate a Response for the 401 Exception.
*
* Unauthorized / Login Requied
* The user should be redirect to a login page.
*
* @return Response
*/
public function get_response()
{
// Todo:: これはどうつくるの?
// Get tpl directory
$home_page = Cms_Helper::settings('home_page');
$response = Response::factory()->status(401)->headers('Location', URL::site($home_page, 'http'));
return $response;
}
示例10: get_response
public function get_response()
{
$response = Response::factory();
$view = Kotwig_View::factory('errors/500');
$response->status(500);
$response->body($view->render());
return $response;
}
示例11: __construct
public function __construct()
{
$this->request = Request::current();
if ($this->request->controller() == "Clients" && $this->request->action() == "detail") {
$this->current_client = new Model_Client($this->request->param('id'));
return $this->current_client;
}
parent::__construct(Request::current(), Response::factory());
}
示例12: get_response
public function get_response()
{
$response = Response::factory();
$view = View::factory('errors/404');
// We're inside an instance of Exception here, all the normal stuff is available.
$view->message = $this->getMessage();
$response->body($view->render());
return $response;
}
示例13: get_response
/**
* Generate a Response for the 404 Exception.
*
* The user should be shown a nice 404 page.
*
* @return Response
*/
public function get_response()
{
//return;
$view = View::factory('404view');
// Remembering that `$this` is an instance of HTTP_Exception_404
// $view->message = $this->getMessage();
$view->message = "Страница не найдена";
$response = Response::factory()->status(404)->body($view->render());
return $response;
}
示例14: get_response
/**
* Generates a Response for all Exceptions without a specific override
*
* @return Response
*/
public function get_response()
{
// Log the exception
Kohana_Exception::log($this);
$response = Response::factory();
$view = Swiftriver::get_base_error_view();
$view->content = View::factory('pages/errors/404')->set('page', $this->request()->uri());
$response->body($view->render());
return $response;
}
示例15: send
/**
* @return Response
*/
public function send()
{
$this->_setProperAccountancyMonth();
$content = $this->_invoice->toJson();
$this->_initCurrentCurl(self::API_INVOICE_URL);
$key = Utils::hexToStr($this->_getConfig()->{Config::API_KEY_INVOICE});
$messageHash = Utils::hmac($key, sprintf("%s%s%s%s", self::API_INVOICE_URL, $this->_getConfig()->{Config::API_LOGIN}, Config::API_KEY_INVOICE_NAME, $content));
$this->_setCurlPostOptions(self::API_INVOICE_URL, $this->_getRequestHeaders($messageHash), $content);
return Response::factory(curl_exec($this->_currentCurl));
}