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


PHP Response::setContent方法代码示例

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


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

示例1: _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

示例2: renderBrowser

 /**
  * Renders the uncaught exception for browser consumption.
  * 
  * @param  Phalcon\Http\Response  $response
  * @param  \Exception $exception
  * @return void
  */
 protected function renderBrowser(Response $response, Exception $exception)
 {
     if ($this->config->debug) {
         $response->setContent($exception->getMessage() . ': ' . $exception->getTraceAsString());
     } else {
         $response->setContent('Sorry, an error has occured.');
     }
 }
开发者ID:halfbakedsneed,项目名称:phalcore,代码行数:15,代码来源:Handler.php

示例3: send

 /**
  * 发送响应消息
  *
  * @param   string  $message    响应信息
  * @param   int     $status     响应状态码
  */
 public static function send($message = '', $status = 200)
 {
     if (self::$response === null) {
         self::init();
     }
     self::$response->setStatusCode(intval($status));
     self::$response->setContent(strval($message));
     self::$response->send();
 }
开发者ID:q-phalcon,项目名称:kernel,代码行数:15,代码来源:QpResponse.php

示例4: reset

 public function reset()
 {
     static::$disableSession = false;
     static::$disableCsrfCheck = false;
     $this->cookies->reset();
     $this->response->setContent('')->resetHeaders()->setStatusCode(200);
 }
开发者ID:phwoolcon,项目名称:phwoolcon,代码行数:7,代码来源:Router.php

示例5: 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

示例6: 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

示例7: accessToken

 /**
  * Exchange a request token for an access token.
  * The exchange is only succesful iff the request token has been authorized.
  *
  * Never returns, calls exit() when token is exchanged or when error is returned.
  */
 public function accessToken()
 {
     try {
         $this->verifyRequest(self::TOKEN_TYPE_REQUEST);
         $options = array();
         $ttl = $this->request->get('xoauth_token_ttl');
         if ($ttl) {
             $options['token_ttl'] = $ttl;
         }
         $verifier = $this->request->get('oauth_verifier');
         if ($verifier) {
             $options['verifier'] = $verifier;
         }
         $store = $this->store;
         $token = $store->exchangeConsumerRequestForAccessToken($this->request->getParam('oauth_token', true), $options);
         /** @var /Foundation/Oauth/Secrets $token */
         $content = array("oauth_token" => $token->token, "oauth_token_secret" => $token->token_secret);
         if ($token->ttl) {
             $content['xoauth_token_ttl'] = $token->ttl;
         }
         $this->response->setContent(http_build_query($content));
         $this->response->setStatusCode(200, "");
         $this->response->setContentType("application/x-www-form-urlencoded");
     } catch (OauthException $e) {
         $this->response->setStatusCode(401, "OAuth Verification Failed: " . $e->getMessage());
     }
     return $this->response;
 }
开发者ID:kathynka,项目名称:Foundation,代码行数:34,代码来源:OauthService.php

示例8: 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

示例9: 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

示例10: debugEnvAction

 public function debugEnvAction()
 {
     //var_dump($_SERVER['REDIRECT_URL']);die();
     $actual_route = $_SERVER['REDIRECT_URL'];
     $response = new Response();
     $response->setStatusCode(404, "Not Found");
     $response->setContent("Sorry, the route: <b>" . $actual_route . " </b> doesn't exist");
     $response->send();
     return $response;
 }
开发者ID:leyriel,项目名称:allocuisto_dev,代码行数:10,代码来源:NotFoundController.php

示例11: send

 /**
  * 向Client发送响应的资源
  */
 public function send()
 {
     if (is_array($this->resource) || is_object($this->resource)) {
         $this->response->setHeader('Content-Type', 'text/json');
         $this->response->setContent(json_encode($this->resource, true));
     } else {
         $this->response->setContent($this->resource);
     }
     $this->response->send();
 }
开发者ID:sujinw,项目名称:passport,代码行数:13,代码来源:BaseController.php

示例12: previewAction

 /**
  * @return Response
  */
 public function previewAction()
 {
     $response = new Response();
     if ($this->request->isPost()) {
         if ($this->session->get('identity')) {
             $content = $this->request->getPost('content');
             $response->setContent($this->markdown->render($this->escaper->escapeHtml($content)));
         }
     }
     return $response;
 }
开发者ID:kjmtrue,项目名称:phalcon-tip,代码行数:14,代码来源:UtilsController.php

示例13: response

 public function response($data = array(), $status = 200, $token = null)
 {
     $response = new Response();
     $response->setStatusCode($status);
     $response->setContent(!empty($this->_statuses[$status]) ? $this->_statuses[$status] : null);
     $response->setHeader('Content-type', 'application/json');
     $response->setHeader('api-version', '1.0');
     $response->setHeader('singou-token', $token);
     $response->setJsonContent($data);
     return $response;
 }
开发者ID:zhuo-jiejie,项目名称:rest-server,代码行数:11,代码来源:BaseController.php

示例14: process

 /**
  * Выполняет все плагины по цепочке
  * 
  * @param \Phalcon\Http\Request $request
  * @return string
  */
 public function process(Request $request)
 {
     $response = new Response();
     $pluginResult = new PluginResult();
     foreach ($this->_arPlugins as $plugin) {
         $pluginResult = $plugin->process($request, $pluginResult);
         if ($pluginResult->terminate) {
             break;
         }
     }
     if ($pluginResult->error) {
         $response->setStatusCode($pluginResult->errorCode, $pluginResult->errorMessage);
         $response->setContent($pluginResult->errorMessage);
         return $response;
     } else {
         $response->setStatusCode(200, "OK");
     }
     $callback = $request->getQuery('callback');
     $result = '';
     if ($callback) {
         $response->setHeader('Content-Type', 'application/javascript');
         $result .= $callback . '(';
     } else {
         $response->setHeader('Content-Type', 'application/json');
     }
     $result .= json_encode(array('searchContext' => $pluginResult->searchContext, 'result' => $pluginResult->result));
     if ($callback) {
         $result .= ');';
     }
     if ($pluginResult->fileToSend) {
         $response->setFileToSend($pluginResult->fileToSend, 'data.txt');
     } else {
         $response->setContent($result);
     }
     return $response;
 }
开发者ID:olegabr,项目名称:kladrapi,代码行数:42,代码来源:ApiService.php

示例15: indexAction

    /**
     * Generate the website robots.txt
     */
    public function indexAction()
    {
        $response = new Response();
        $expireDate = new \DateTime();
        $expireDate->modify('+1 month');
        $response->setExpires($expireDate);
        $response->setHeader('Content-Type', "text/plain; charset=UTF-8");
        $baseUrl = rtrim($this->config->site->url, '/');
        $content = <<<EOL
User-agent: *
Allow: /
Sitemap: {$baseUrl}/sitemap
EOL;
        $response->setContent($content);
        return $response;
    }
开发者ID:huoybb,项目名称:forum,代码行数:19,代码来源:RobotsController.php


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