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


PHP Response::setContent方法代码示例

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


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

示例1: run

 public function run()
 {
     $route = $this->router->match($this->request);
     if ($route === false) {
         $actionName = self::ACTION_NOT_FOUND;
     } else {
         $actionName = $route->getName();
     }
     if (!$this->actions->has($actionName)) {
         throw new \Exception(sprintf('Action %s not found', $actionName));
     }
     $this->store->setFileName($actionName);
     if ($this->request->isAjax()) {
         $this->view->setRenderType(View::RENDER_JSON);
     } else {
         $this->view->setContentView('error');
     }
     $action = $this->actions->get($actionName);
     call_user_func_array($action, array($this));
     if (is_callable($this->postAction)) {
         call_user_func_array($this->postAction, array($this));
     }
     $this->response->setContent($this->view->render());
     $this->response->send();
 }
开发者ID:Acidburn0zzz,项目名称:devtools-1,代码行数:25,代码来源:Application.php

示例2: preview_page

 public function preview_page()
 {
     $page = Page::getByID(intval($_REQUEST['cID'], 10), 'RECENT');
     if (!is_object($page) || $page->isError()) {
         throw new \InvalidArgumentException('Invalid collection ID');
     }
     $permissions = new Permissions($page);
     if ($permissions->canPreviewPageAsUser() && $permissions->canRead() && Config::get('concrete.permissions.model') == 'advanced') {
         /** @var Request $request */
         $request = Request::getInstance();
         $request->setCustomRequestUser(false);
         $request->setCurrentPage($page);
         if ($request->request('customUser')) {
             $user_info = UserInfo::getByUserName($request->request('customUser'));
             if ($user_info && is_object($user_info) && !$user_info->isError()) {
                 $request->setCustomRequestUser($user_info);
             }
         }
         $request->setCustomRequestDateTime(Core::make('helper/form/date_time')->translate('preview_as_user_datetime', $request->request()));
         $controller = $page->getPageController();
         $view = $controller->getViewObject();
         $response = new \Response();
         $response->setContent($view->render());
         $response->send();
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:26,代码来源:preview_as_user.php

示例3: preview

 public function preview()
 {
     $request = \Request::getInstance();
     $c = \Page::getByID($this->request->get('cID'));
     $cp = new \Permissions($c);
     if ($cp->canViewPageVersions()) {
         $c->loadVersionObject(\Core::make('helper/security')->sanitizeInt($_REQUEST['cvID']));
         $spoofed_request = \Request::createFromGlobals();
         if ($device_handle = $request->headers->get('x-device-handle')) {
             if ($device = \Core::make('device/manager')->get($device_handle)) {
                 if ($agent = $device->getUserAgent()) {
                     $spoofed_request->headers->set('User-Agent', $agent);
                 }
             }
         }
         $spoofed_request->setCustomRequestUser(-1);
         $spoofed_request->setCurrentPage($c);
         \Request::setInstance($spoofed_request);
         $controller = $c->getPageController();
         $controller->runTask('view', array());
         $view = $controller->getViewObject();
         $response = new \Response();
         $content = $view->render();
         // Reset just in case.
         \Request::setInstance($request);
         $response->setContent($content);
         $response->send();
         exit;
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:30,代码来源:devices.php

示例4: parse

 /**
  * Parses a raw response string, including headers and body, and returns a Response object.
  *
  * @param string $response
  *
  * @return \Brick\Http\Response
  *
  * @throws \RuntimeException
  */
 public static function parse($response)
 {
     $responseObject = new Response();
     if (preg_match('/^HTTP\\/([0-9]\\.[0-9]) ([0-9]{3}) .*\\r\\n/', $response, $matches) == 0) {
         throw new \RuntimeException('Could not parse response (error 1).');
     }
     list($line, $protocolVersion, $statusCode) = $matches;
     $responseObject->setProtocolVersion($protocolVersion);
     $responseObject->setStatusCode($statusCode);
     $response = substr($response, strlen($line));
     for (;;) {
         $pos = strpos($response, Message::CRLF);
         if ($pos === false) {
             throw new \RuntimeException('Could not parse response (error 2).');
         }
         if ($pos == 0) {
             break;
         }
         $header = substr($response, 0, $pos);
         if (preg_match('/^(\\S+):\\s*(.*)$/', $header, $matches) == 0) {
             throw new \RuntimeException('Could not parse response (error 3).');
         }
         list($line, $name, $value) = $matches;
         if (strtolower($name) == 'set-cookie') {
             $responseObject->setCookie(Cookie::parse($value));
         } else {
             $responseObject->addHeader($name, $value);
         }
         $response = substr($response, strlen($line) + 2);
     }
     $body = substr($response, 2);
     $responseObject->setContent($body);
     return $responseObject;
 }
开发者ID:brick,项目名称:http,代码行数:43,代码来源:Response.php

示例5: ajaxSetDate

 /**
  * AJAX call for set payment and cancel dates on Dossier details page (Financial > Price)
  *
  * @Route("/ajax/set/date", name="payment_ajax_set_date")
  */
 public function ajaxSetDate(Request $request)
 {
     $type = $request->get('type');
     $dateType = $request->get('dateType');
     $dossierId = $request->get('dossierId');
     $paymentId = $request->get('paymentId');
     $value = $request->get('value');
     $em = $this->getDoctrine()->getManager();
     $dossier = $em->getRepository('BraemBackofficeBundle:Dossier')->find($dossierId);
     if (!$dossier) {
         throw $this->createNotFoundException('Unable to find Dossier entity.');
     }
     $payment = $this->getCurrentPayment($paymentId, $type, $dossierId);
     $hasPayment = $payment->getId() ? true : false;
     if (!$hasPayment) {
         $payment->setDossier($dossier);
         $user = $this->container->get('security.context')->getToken()->getUser();
         $payment->setUser($user);
     }
     $payment->setType($type);
     $dateSetter = 'set' . ucfirst($dateType);
     $date = \DateTime::createFromFormat('d/m/Y', $value);
     $payment->{$dateSetter}($date);
     $em->persist($payment);
     $em->flush();
     $dateTitle = $this->getTitleForDate($dateType);
     $dateTitleReturn = $this->get('translator')->trans($dateTitle);
     $valueArr = explode('/', $value);
     $valueReturn = $valueArr[2] . '-' . $valueArr[1] . '-' . $valueArr[0];
     $dateTypeReturn = str_replace('Date', '', $dateType);
     $response = array('type' => $type, 'dateType' => $dateTypeReturn, 'dossierId' => $dossierId, 'paymentId' => $payment->getId(), 'value' => $valueReturn, 'title' => $dateTitleReturn);
     $return = new Response();
     $return->setContent(json_encode($response));
     return $return;
 }
开发者ID:rainlike,项目名称:flinders,代码行数:40,代码来源:PaymentController.php

示例6: process

 public function process()
 {
     $gb = mGuestBook::getInstance();
     $newMsgs = $gb->getSince(array("n", "nick", "email", "date", "msg", "admin_answer", "admin_answer_date"), Request::getVarAsInteger("lastN", "POST"));
     Response::setContent($this->_view->compose($newMsgs));
     return true;
 }
开发者ID:nirwander,项目名称:holkinsengine,代码行数:7,代码来源:ctrlWannaNewMsgs.class.php

示例7: abort

function abort($code)
{
    $response = new Response();
    $response->addHeader('Content-Type: text/html; charset=utf-8');
    $response->setIsHtml(true);
    $response->setContent('error.' . $code);
    return $response;
}
开发者ID:BenjaminLu,项目名称:ToyLara,代码行数:8,代码来源:response.helper.php

示例8: render

 /**
  * Gets merged content form layout and page.
  *
  * @param string $template
  * @param array  $data
  *
  * @return Response
  *
  * @throws Exception
  */
 public function render($template, $data = [])
 {
     $response = new Response();
     $pageContent = $this->getPageContent($template, $data);
     $content = $this->getLayoutContent($pageContent, $data);
     $response->setContent($content);
     return $response;
 }
开发者ID:serkin,项目名称:blog,代码行数:18,代码来源:Controller.php

示例9: testIfContentIsAppendedCorrectly

 /**
  * @test
  */
 public function testIfContentIsAppendedCorrectly()
 {
     $response = new Response();
     $response->setContent('<html>');
     $this->assertEquals('<html>', $response->getContent());
     $response->appendContent('</html>');
     $this->assertEquals('<html></html>', $response->getContent());
 }
开发者ID:lcobucci,项目名称:action-mapper,代码行数:11,代码来源:ResponseTest.php

示例10: show

 function show()
 {
     $configuration = new Config();
     $database = new SafeMySQL(array('user' => $configuration->db->username, 'pass' => $configuration->db->password, 'db' => $configuration->db->database, 'charset' => $configuration->db->charset));
     $data = $database->getAll('SELECT * FROM students');
     $response = new Response();
     $response->setContent(json_encode($data));
     $response->send();
 }
开发者ID:jenyaukraine,项目名称:mindk,代码行数:9,代码来源:Students.class.php

示例11: responseFromOAuth

 /**
  * Creates Phalcon response from OAuth2 Response.
  *
  * @param $oauth_response
  * @return Response
  */
 public static function responseFromOAuth($oauth_response)
 {
     $response = new Response();
     $response->setStatusCode($oauth_response->getStatusCode());
     foreach ($oauth_response->getHttpHeaders() as $header) {
         $response->setRawHeader($header);
     }
     $response->setContent($oauth_response->getResponseBody());
     return $response;
 }
开发者ID:soutoner,项目名称:api-desconecta,代码行数:16,代码来源:Response.php

示例12: testResponse

 public function testResponse()
 {
     $response = new Response();
     $response->setContent('some output');
     ob_start();
     $response->send();
     $output = ob_get_contents();
     ob_end_clean();
     $this->assertEquals('some output', $output);
 }
开发者ID:poliander,项目名称:janeiro,代码行数:10,代码来源:ResponseTest.php

示例13: setContent

 /**
  * Prepares the content
  * @param   mixed
  * @param   integer
  * @param   integer
  */
 public function setContent($varContent, $intOptions = 0, $intDepth = 512)
 {
     // Depth parameter is only supported from PHP 5.5
     if (version_compare(PHP_VERSION, '5.5', '>=')) {
         $strContent = json_encode($varContent, $intOptions, $intDepth);
     } else {
         $strContent = json_encode($varContent, $intOptions);
     }
     parent::setContent($strContent);
 }
开发者ID:codefog,项目名称:contao-haste,代码行数:16,代码来源:JsonResponse.php

示例14: process

 public function process()
 {
     $params = array();
     $params["title"] = array(array("title" => "Kirillka-after-party!"));
     $gb = mGuestBook::getInstance();
     $params["guestBookSite"] = $gb->getPage(array("n", "nick", "email", "date", "msg", "admin_answer", "admin_answer_date"), 1);
     $c = $this->_view->compose($params);
     Response::setContent($c);
     return true;
 }
开发者ID:nirwander,项目名称:holkinsengine,代码行数:10,代码来源:ctrlAfter.class.php

示例15: process

 public function process()
 {
     $params = array();
     $params["title"] = array(array("title" => "Привет!"));
     $party = mParty::getInstance();
     $res = $party->chooseCharacter(Request::getVarAsInteger("guest", "POST"), Request::getVarAsInteger("id", "POST"), Request::getVarAsInteger("character", "POST"));
     $c = $this->_view->compose($res);
     Response::setContent($c);
     return true;
 }
开发者ID:nirwander,项目名称:holkinsengine,代码行数:10,代码来源:ctrlIdentity.class.php


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