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