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


PHP Http\Response類代碼示例

本文整理匯總了PHP中Phalcon\Http\Response的典型用法代碼示例。如果您正苦於以下問題:PHP Response類的具體用法?PHP Response怎麽用?PHP Response使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: getCsrfTokenAction

 /**
  * Get CSRF token for Ajax request.
  * @return a HTTP response object with JSON
  */
 public function getCsrfTokenAction()
 {
     $result = array('csrfTokenKey' => $this->security->getTokenKey(), 'csrfToken' => $this->security->getToken());
     $response = new Response();
     $response->setContent(json_encode($result));
     return $response;
 }
開發者ID:kelliany,項目名稱:TestZilla,代碼行數:11,代碼來源:DefaultController.php

示例2: returnResult

 public function returnResult($result, $errorMessage = null)
 {
     $response = new Response();
     $result = ['result' => $result, 'status' => $errorMessage === null ? self::SUCCESS_RESPONSE : self::FAILED_RESPONSE, 'error_message' => (string) $errorMessage];
     $response->setJsonContent($result);
     return $response;
 }
開發者ID:boorlyk,項目名稱:friendsApi,代碼行數:7,代碼來源:RestController.php

示例3: setUp

 /**
  *
  */
 public function setUp()
 {
     $di = new DI();
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_SERVER['REQUEST_URI'] = '/path?foo=aaa&bar=bbb';
     $_GET = array('_url' => '/path', 'foo' => 'aaa', 'bar' => 'bbb');
     $request = new Request();
     $request->setDI($di);
     $this->request = $request;
     $response = new Response();
     $response->setDI($di);
     $dispatcher = new Dispatcher();
     $dispatcher->setDI($di);
     $this->dispatcher = $dispatcher;
     $cache = new BackendCache(new FrontendCache());
     $di->set('viewCache', $cache);
     $config = new Config(array('cache' => array('enable' => true)));
     $di->set('config', $config);
     $eventsManager = new Manager();
     $di->set('request', $request, true);
     $di->set('response', $response, true);
     $di->set('dispatcher', $dispatcher, true);
     $di->set('eventsManager', $eventsManager);
     $this->di = $di;
     $application = new Application();
     $application->setDI($di);
     $application->setEventsManager($eventsManager);
     $this->application = $application;
 }
開發者ID:hushibing,項目名稱:EvaEngine,代碼行數:33,代碼來源:DispatchTest.php

示例4: rawAction

 public function rawAction()
 {
     $plain_response = new Response();
     $plain_response->setHeader("Content-Type", "text/plain");
     $plain_response->setContent($this->paste->content);
     return $plain_response;
 }
開發者ID:carriercomm,項目名稱:Phaste,代碼行數:7,代碼來源:ViewController.php

示例5: setUp

 public function setUp()
 {
     $di = new DI();
     $_SERVER['HTTP_HOST'] = 'example.com';
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_SERVER['REQUEST_URI'] = '/path?foo=aaa&bar=bbb';
     $_GET = array('_url' => '/path', 'foo' => 'aaa', 'bar' => 'bbb');
     $request = new Request();
     $request->setDI($di);
     $this->request = $request;
     $response = new Response();
     $response->setDI($di);
     $this->response = $response;
     $eventsManager = new Manager();
     $cors = new Cors(array(array('domain' => 'bar.com')));
     $di->set('request', $request, true);
     $di->set('response', $response, true);
     $di->set('eventsManager', $eventsManager);
     $di->set('cors', $cors);
     $this->di = $di;
     $application = new Application();
     $application->setDI($di);
     $application->setEventsManager($eventsManager);
     $this->application = $application;
 }
開發者ID:evaengine,項目名稱:evaengine,代碼行數:25,代碼來源:CorsTest.php

示例6: _renderJsonp

 /**
  * @param View $view
  */
 protected function _renderJsonp(View $view)
 {
     $content = $this->getResponse()->setContentType('application/json')->setJsonContent($view->getParamsToView())->getContent();
     $content = $this->request->get('callback') . '(' . $content . ')';
     $this->response->setContent($content)->send();
     $view->setRenderLevel(View::LEVEL_NO_RENDER);
 }
開發者ID:aisuhua,項目名稱:vkplay,代碼行數:10,代碼來源:Context.php

示例7: uploadAction

 public function uploadAction()
 {
     $this->mediaModel = new Media();
     if ($this->request->hasFiles() == true) {
         $uploads = $this->request->getUploadedFiles();
         $this->view->disable();
         $uploaded = true;
         foreach ($uploads as $fileObj) {
             if (!$this->mediaModel->initFile($fileObj)) {
                 $uploaded = false;
             }
         }
         $response = new Response();
         if (!$uploaded) {
             $error = implode("\n", $this->mediaModel->getError());
             $response->setStatusCode(406, $error);
         } else {
             $response->setStatusCode(200, "Success");
         }
         return $response;
     } else {
         $this->assets->addCss('/core/assets/css/dropzone.css', false);
         $this->assets->addJs('/core/assets/js/dropzone.js', false);
         $this->view->acceptExt = implode(",", $this->constants->mediaAcceptFilesExt());
     }
 }
開發者ID:kjmtrue,項目名稱:phanbook,代碼行數:26,代碼來源:MediaController.php

示例8: jsonResponse

 protected function jsonResponse($data)
 {
     $response = new Response();
     $response->setContentType('application/json', 'UTF-8');
     $response->setJsonContent($data);
     return $response;
 }
開發者ID:caiofralmeida,項目名稱:soccer-company-event,代碼行數:7,代碼來源:BaseController.php

示例9: response

 /**
  * @return Response
  */
 public function response()
 {
     if ($this->__response === null) {
         $this->__response = new Response();
         $this->__response->setStatusCode(200);
     }
     return $this->__response;
 }
開發者ID:serus22,項目名稱:phalconz,代碼行數:11,代碼來源:BaseController.php

示例10: logoutAction

 /**
  * Logout user, destroying session and invalidating remember me cookie. Forwards to login form.
  */
 public function logoutAction()
 {
     $response = new Response();
     $response->setCookies($this->cookies->set('username', '', strtotime('-1 year')));
     $response->setCookies($this->cookies->set('password', '', strtotime('-1 year')));
     $this->session->destroy();
     return $response->redirect('session/index');
 }
開發者ID:joszz,項目名稱:Chell-PHP-Portal,代碼行數:11,代碼來源:SessionController.php

示例11: redirect

 /**
  * Returns an Redirect to the given url.
  * 
  * @param string $url
  * @return \Phalcon\Http\Response
  */
 protected function redirect($url, $extraParams = array())
 {
     $response = new Response();
     $response->redirect($url);
     $formReflectionManager = new FormReflectionManager($this->flash);
     $formReflectionManager->add($extraParams + $this->request->get());
     return $response;
 }
開發者ID:sweetdevel,項目名稱:pingaroo,代碼行數:14,代碼來源:BaseController.php

示例12: renderAJAX

 /**
  * Renders the uncaught exception for AJAX consumption.
  * 
  * @param  Phalcon\Http\Response  $response
  * @param  \Exception $exceptio
  * @return void
  */
 protected function renderAJAX(Response $response, Exception $exception)
 {
     if ($this->config->debug) {
         $response->setJsonContent(['_exception' => $exception->getMessage() . ': ' . $exception->getTraceAsString()]);
     } else {
         $response->setJsonContent(['status' => false]);
     }
 }
開發者ID:halfbakedsneed,項目名稱:phalcore,代碼行數:15,代碼來源:Handler.php

示例13: respond

 /**
  * Send response to client
  */
 public function respond($data, $status = 200)
 {
     $response = new Response();
     $response->setContentType('application/json');
     $response->setStatusCode($status);
     $data = $data instanceof SimpleResultSet ? $data->toArray() : $data;
     $response->setContent(json_encode($data));
     $response->send();
 }
開發者ID:bilna-dev,項目名稱:monitoring-tools,代碼行數:12,代碼來源:Restable.php

示例14: indexAction

 /**
  * Default action.
  */
 public function indexAction()
 {
     $this->view->disable();
     $data = ['Hello', 'World'];
     $content = json_encode($data);
     $response = new Response();
     $response->setContent($content);
     return $response;
 }
開發者ID:rub3nlh,項目名稱:webird,代碼行數:12,代碼來源:HelloworldController.php

示例15: sendResult

 /**
  * 發送數據
  * @param mixed $result
  */
 private static function sendResult($result)
 {
     $response = new Response();
     $response->setHeader('Content-Type', 'application/json; charset=UTF-8');
     $response->setHeader('Access-Control-Allow-Origin', '*');
     $response->setJsonContent($result);
     $response->send();
     exit;
 }
開發者ID:huxiaohe,項目名稱:api-framework,代碼行數:13,代碼來源:ResponseApi.php


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