当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::body方法代码示例

本文整理汇总了PHP中Response::body方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::body方法的具体用法?PHP Response::body怎么用?PHP Response::body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response::body方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: after

 /**
  * This method gets called after the action is called.
  *
  * @param mixed $response Value returned from the action method.
  * 
  * @return Response $response
  */
 public function after($response)
 {
     // Return if passed a response.
     if ($response instanceof Response) {
         return parent::after($response);
     }
     if ($this->autorender) {
         try {
             $this->view->set_filename(Str::lower(str_replace('_', '/', Inflector::denamespace(str_replace('controller_', '', Str::lower($this->request->controller)))) . DS . str_replace('_', '/', $this->request->action)));
         } catch (FuelException $e) {
         }
     }
     // Inject view into the layout if the main request.
     if ($this->layout instanceof View) {
         if ($this->autorender) {
             try {
                 // Throws exception if there is no view template found.
                 $this->layout->content = $this->view->render();
             } catch (FuelException $e) {
             }
         }
         $this->layout->content_data = $this->view->get();
         $this->response->body($this->layout);
     } else {
         $this->response->body($this->view);
     }
     return parent::after($this->response);
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:35,代码来源:controller.php

示例2: test_body

 /**
  * Tests that we can set and read a body of a response
  * 
  * @test
  * @dataProvider provider_body
  *
  * @return null
  */
 public function test_body($source, $expected)
 {
     $response = new Response();
     $response->body($source);
     $this->assertSame($response->body(), $expected);
     $response = (string) $response;
     $this->assertSame($response, $expected);
 }
开发者ID:nemni8,项目名称:Munch,代码行数:16,代码来源:ResponseTest.php

示例3: _injectCookieAdvert

 /**
  * Inject the script with the cookie warning
  *
  * @param Response $response : Response
  * @return void
  */
 protected function _injectCookieAdvert($response)
 {
     if (strpos($response->type(), 'html') === false) {
         return;
     }
     $body = $response->body();
     $pos = strrpos($body, '</body>');
     if ($pos === false) {
         return;
     }
     $view = "<iframe src='" . Router::url('/cookie_warning/cookie-warnings/display-info') . "' style='width:100%;position:fixed;top:0;left: 0;z-index:9999' id='cookie_iframe'></iframe>";
     $body = substr($body, 0, $pos) . $view . substr($body, $pos);
     $response->body($body);
 }
开发者ID:cakephp-fr,项目名称:cookie-warning,代码行数:20,代码来源:CookieWarningFilter.php

示例4: handle

 public static function handle(Exception $e)
 {
     switch (get_class($e)) {
         case 'HTTP_Exception_404':
             // Посылаем статус страницы 404
             $response = new Response();
             $response->status(404);
             $response->protocol('HTTP/1.1');
             // Посылаем корректный статус 404 ошибки
             /* header('HTTP/1.0 404 Not Found');
                header('HTTP/1.1 404 Not Found');
                header('Status: 404 Not Found'); */
             // Создаем вид для отображения 404 ошибки
             $view = new View_Error_404('error/404');
             $view->message = $e->getMessage();
             // Если шаблон есть - отображаем страницу ошибки
             if (!empty($view)) {
                 // Выводим шаблон
                 echo $response->send_headers()->body($view->render());
             } else {
                 echo $response->body('<h1>Не найден шаблон для View_Error_404</h1>');
             }
             return true;
             break;
         default:
             Kohana_Exception::handler($e);
     }
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:28,代码来源:exceptionhandler.php

示例5: action_download

 public function action_download($cache_filename)
 {
     if (!$cache_filename) {
         return $this->action_404();
     }
     // add json extension
     $cache_filename .= '.json';
     // load data from cache if possible
     try {
         $data = Cache::get($cache_filename);
     } catch (\CacheNotFoundException $e) {
         return $this->action_404();
     }
     // cache found but empty!?
     if (!$data) {
         return $this->action_404();
     }
     $response = new Response();
     // We'll be outputting a json string
     $response->set_header('Content-Type', 'application/json');
     // It will be called downloaded.pdf
     $response->set_header('Content-Disposition', 'attachment; filename="checkins.json"');
     // Set no cache
     $response->set_header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate');
     $response->set_header('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
     $response->set_header('Pragma', 'no-cache');
     $response->body($data);
     return $response;
 }
开发者ID:neostoic,项目名称:cartoDB-Foursquare-Heatmap,代码行数:29,代码来源:welcome.php

示例6: handle

 public static function handle(Exception $e)
 {
     switch (get_class($e)) {
         case 'HTTP_Exception_404':
             $response = new Response();
             $response->status(404);
             $view = new View('errors/error404');
             Controller_Abstract::add_static();
             if (Kohana::$environment == Kohana::DEVELOPMENT) {
                 $view->message = $e->getMessage();
             }
             echo $response->body($view)->send_headers()->body();
             return TRUE;
             break;
         case 'HTTP_Exception_410':
             $response = new Response();
             $response->status(410);
             $view = new View('errors/error410');
             Controller_Abstract::add_static();
             echo $response->body($view)->send_headers()->body();
             return TRUE;
             break;
         default:
             header('C-Data: ' . uniqid() . str_replace('=', '', base64_encode($e->getMessage())));
             return Kohana_Exception::handler($e);
             break;
     }
 }
开发者ID:nergal,项目名称:2mio,代码行数:28,代码来源:handler.php

示例7: __construct

 public function __construct(\Request $request, \Response $response)
 {
     $this->image = new Model_Image($request->param('id'));
     if (!$this->image->loaded()) {
         $exception = new HTTP_Exception_404(__('This page seems to not exists.'));
         $response->body($exception->get_response()->body());
     }
     parent::__construct($request, $response);
 }
开发者ID:Workhaven,项目名称:workhaven,代码行数:9,代码来源:Images.php

示例8: parse_response

 /**
  * Parses a response from the Codebase API and returns the results as an array,
  * if the response contains any errors an exception is thrown
  *
  * @param	Response			$response
  * @return	array
  * @throws	Codebase_Exception
  * @static
  */
 protected static function parse_response(Response $response)
 {
     if ($response->status() >= 400) {
         throw new Codebase_Exception('HTTP ' . $response->status() . ' error');
     }
     $parsed_result = new SimpleXMLElement($response->body());
     // check for errors?
     return $parsed_result;
 }
开发者ID:rpa-design,项目名称:codebase,代码行数:18,代码来源:core.php

示例9: action_ajax_test_ftp

 public function action_ajax_test_ftp()
 {
     // is ajax
     if (!\Input::is_ajax()) {
         \Response::redirect(\Uri::create('admin'));
     }
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('config_global', 'config_global') == false) {
         \Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
         return null;
     }
     if (\Input::method() == 'POST') {
         // get post value and test connection
         $config['hostname'] = trim(\Input::post('hostname'));
         $config['username'] = trim(\Input::post('username'));
         $config['password'] = trim(\Input::post('password'));
         $config['port'] = (int) trim(\Input::post('port'));
         $config['passive'] = trim(\Input::post('passive')) == 'true' ? true : false;
         $config['ssl_mode'] = false;
         $config['debug'] = false;
         $basepath = trim(\Input::post('basepath'));
         // connect to ftp
         $ftp = \Ftp::forge($config);
         $ftp->connect();
         $ftp->change_dir($basepath);
         $files = $ftp->list_files();
         $ftp->close();
         $output = array();
         if ($files !== false) {
             $output['form_status'] = 'success';
             $output['form_status_message'] = \Lang::get('config_ftp_connected_check_basepath_from_dir_structure_below');
             natsort($files);
             $output['list_files'] = '<ul>';
             foreach ($files as $file) {
                 $output['list_files'] .= '<li>' . $file . '</li>';
             }
             $output['list_files'] .= '</ul>';
         } else {
             // got false from list_files means cannot connect
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('config_ftp_could_not_connect_to_server');
         }
         // clear no use variables
         unset($basepath, $config, $file, $files, $ftp);
         // send out json values
         $response = new \Response();
         $response->set_header('Content-Type', 'application/json');
         $response->body(json_encode($output));
         return $response;
     }
 }
开发者ID:rundiz,项目名称:fuel-start,代码行数:51,代码来源:config.php

示例10: handle

 public static function handle(Exception $e)
 {
     switch (get_class($e)) {
         case 'HTTP_Exception_404':
             $response = new Response();
             $response->status(404);
             $request = Request::factory('404error')->method(Request::POST)->post(array('message' => $e->getMessage()))->execute();
             echo $response->body($request)->send_headers()->body();
             return TRUE;
             break;
         default:
             return Kohana_Exception::handler($e);
             break;
     }
 }
开发者ID:Alexander711,项目名称:naav1,代码行数:15,代码来源:exceptionhandler.php

示例11: performCommonAssertionsAndGetRecords

 /**
  * Utility function to drilldown to the records returned by the request
  * 
  * @param Response $response
  * @param string|null $modelShortName
  * @param int $code
  * @return array
  */
 protected function performCommonAssertionsAndGetRecords($response, $modelShortName = null, $code = 200)
 {
     if (!$modelShortName) {
         $modelShortName = $this->buildModelShortName();
     }
     $responseData = json_decode($response->body(), true);
     // perform the status assertion after we get the body. sometimes it's helpful
     // during debugging to inspect the $responseData without being short-circuited
     // by the failure on the status test
     $this->assertEquals($code, $response->status());
     $this->assertInternalType('array', $responseData);
     $this->assertArrayHasKey($modelShortName, $responseData);
     $records = $responseData[$modelShortName];
     $this->assertInternalType('array', $records);
     return $records;
 }
开发者ID:dwsla,项目名称:deal,代码行数:24,代码来源:AbstractControllerTest.php

示例12: handler

 /**
  * Overriden to show custom page for 404 errors
  */
 public static function handler(Exception $e)
 {
     switch (get_class($e)) {
         case 'HTTP_Exception_404':
             $response = new Response();
             $response->status(404);
             //  $view = new View('errors/report');
             // $view->message = $e->getMessage();
             echo $response->body("<h2>Page Not Found</h2> <a href=\"/\" >Go Home</a>")->send_headers()->body();
             return TRUE;
             break;
         default:
             return Kohana_Kohana_Exception::handler($e);
             break;
     }
 }
开发者ID:kanikaN,项目名称:qload,代码行数:19,代码来源:exception.php

示例13: handle

 public static function handle(Exception $e)
 {
     switch (get_class($e)) {
         case 'Http_Exception_404':
             $response = new Response();
             $response->status(404);
             $view = new View('404view');
             $view->message = $e->getMessage();
             echo $response->body($view)->send_headers()->body();
             return TRUE;
             break;
         default:
             return Kohana_Exception::handler($e);
             break;
     }
 }
开发者ID:sysdevbol,项目名称:entidad,代码行数:16,代码来源:exceptionhandler.php

示例14: __construct

 /**
  * 构造函数
  *+-----------------------
  * @param Request $request
  * @param Arry $routes
  * @return Void
  */
 public function __construct(Request &$request, Response &$response, $routes)
 {
     $file = $this->mapPath($routes);
     $rc = new ReflectionClass($this->controller);
     if (!$rc->isAbstract() && $rc->isSubclassOf('Controller')) {
         $controller = new $this->controller($request);
         if (method_exists($controller, $this->action)) {
             ob_start();
             $this->invoke($controller);
             $content = ob_get_contents();
             ob_end_clean();
             $response->body($content);
             $response->status(200);
             return true;
         }
     }
     throw new Ada_Exception('The requested URL was not found on this server');
 }
开发者ID:adawongframework,项目名称:project,代码行数:25,代码来源:Internal.php

示例15: handler

 /**
  * Inline exception handler, displays the error message, source of the
  * exception, and the stack trace of the error.
  *
  * @uses    Kohana_Exception::text
  * @param   object   exception object
  * @return  boolean
  */
 public static function handler(Exception $e)
 {
     $response = new Response();
     switch (get_class($e)) {
         case 'HTTP_Exception_404':
             $view = new View_Error_404();
             $view->message = $e->getMessage();
             $response->status(404);
             $view->title = 'File Not Found';
             break;
         default:
             $view = new View_Error_500();
             $view->message = $e->getMessage();
             $response->status(500);
             $view->title = 'NOMNOMNOMN';
             break;
     }
     echo $response->body($view)->send_headers()->body();
 }
开发者ID:kohana,项目名称:kohanaframework.org,代码行数:27,代码来源:exception.php


注:本文中的Response::body方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。