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


PHP Response::sendContent方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\Response::sendContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Response::sendContent方法的具體用法?PHP Response::sendContent怎麽用?PHP Response::sendContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\Response的用法示例。


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

示例1: sendContent

 /**
  * Sends the file.
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     $outStream = fopen('php://output', 'wb');
     $fileStream = $this->file->readStream();
     stream_copy_to_stream($fileStream, $outStream);
     fclose($outStream);
     fclose($fileStream);
 }
開發者ID:Fedott,項目名稱:secure-file-storage,代碼行數:15,代碼來源:StreamFileResponse.php

示例2: sendContent

 /**
  * Sends content for the current web response.
  *
  * @param ReactResponse   $response
  * @param SymfonyResponse $sf_response
  */
 private function sendContent(ReactResponse $response, SymfonyResponse $sf_response)
 {
     if ($sf_response instanceof StreamedResponse || $sf_response instanceof BinaryFileResponse) {
         ob_start(function ($buffer) use($response) {
             $response->write($buffer);
         });
         $sf_response->sendContent();
         ob_get_clean();
         $response->end();
     } else {
         $response->end($sf_response->getContent());
     }
 }
開發者ID:KEIII,項目名稱:react-silex,代碼行數:19,代碼來源:ResponseBridge.php

示例3: sendContent

 /**
  * Sends the file.
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     if (0 === $this->maxlen) {
         return;
     }
     $out = fopen('php://output', 'wb');
     $file = fopen($this->file->getPathname(), 'rb');
     stream_copy_to_stream($file, $out, $this->maxlen, $this->offset);
     fclose($out);
     fclose($file);
 }
開發者ID:Gordondalos,項目名稱:erp,代碼行數:18,代碼來源:BinaryFileResponse.php

示例4: testSendContent

 public function testSendContent()
 {
     $response = new Response('test response rendering', 200);
     ob_start();
     $response->sendContent();
     $string = ob_get_clean();
     $this->assertContains('test response rendering', $string);
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:8,代碼來源:ResponseTest.php

示例5: deliver

 /**
  * Delivers the Response as a string.
  *
  * When the Response is a StreamedResponse, the content is streamed immediately
  * instead of being returned.
  *
  * @param Response $response A Response instance
  *
  * @return string|null The Response content or null when the Response is streamed
  *
  * @throws \RuntimeException when the Response is not successful
  */
 protected function deliver(Response $response)
 {
     if (!$response->isSuccessful()) {
         throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requests[0]->getUri(), $response->getStatusCode()));
     }
     if (!$response instanceof StreamedResponse) {
         return $response->getContent();
     }
     $response->sendContent();
 }
開發者ID:ronaldlunaramos,項目名稱:webstore,代碼行數:22,代碼來源:FragmentHandler.php

示例6: filterResponse

 /**
  * Converts the HttpKernel response to a BrowserKit response.
  *
  * @param Response $response A Response instance
  *
  * @return DomResponse A DomResponse instance
  */
 protected function filterResponse($response)
 {
     $headers = $response->headers->all();
     if ($response->headers->getCookies()) {
         $cookies = array();
         foreach ($response->headers->getCookies() as $cookie) {
             $cookies[] = new DomCookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
         }
         $headers['Set-Cookie'] = $cookies;
     }
     // this is needed to support StreamedResponse
     ob_start();
     $response->sendContent();
     $content = ob_get_clean();
     return new DomResponse($content, $response->getStatusCode(), $headers);
 }
開發者ID:omusico,項目名稱:lafayettehelps.com,代碼行數:23,代碼來源:Client.php

示例7: createResponse

 /**
  * {@inheritdoc}
  */
 public function createResponse(Response $symfonyResponse)
 {
     if ($symfonyResponse instanceof BinaryFileResponse) {
         $stream = new DiactorosStream($symfonyResponse->getFile()->getPathname(), 'r');
     } else {
         $stream = new DiactorosStream('php://temp', 'wb+');
         if ($symfonyResponse instanceof StreamedResponse) {
             ob_start(function ($buffer) use($stream) {
                 $stream->write($buffer);
                 return false;
             });
             $symfonyResponse->sendContent();
             ob_end_clean();
         } else {
             $stream->write($symfonyResponse->getContent());
         }
     }
     $headers = $symfonyResponse->headers->all();
     $cookies = $symfonyResponse->headers->getCookies();
     if (!empty($cookies)) {
         $headers['Set-Cookie'] = array();
         foreach ($cookies as $cookie) {
             $headers['Set-Cookie'][] = $cookie->__toString();
         }
     }
     $response = new DiactorosResponse($stream, $symfonyResponse->getStatusCode(), $headers);
     $protocolVersion = $symfonyResponse->getProtocolVersion();
     if ('1.1' !== $protocolVersion) {
         $response = $response->withProtocolVersion($protocolVersion);
     }
     return $response;
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:35,代碼來源:DiactorosFactory.php

示例8: sendContent

 /**
  * Sends the file.
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     if (0 === $this->maxlen) {
         return;
     }
     $out = fopen('php://output', 'wb');
     $in = $this->ioService->getFileInputStream($this->file);
     stream_copy_to_stream($in, $out, $this->maxlen, $this->offset);
     fclose($out);
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:17,代碼來源:BinaryStreamResponse.php

示例9: filterResponse

    /**
     * Converts the HttpKernel response to a BrowserKit response.
     *
     * @param Response $response A Response instance
     *
     * @return DomResponse A DomResponse instance
     */
    protected function filterResponse($response)
    {
        // this is needed to support StreamedResponse
        ob_start();
        $response->sendContent();
        $content = ob_get_clean();

        return new DomResponse($content, $response->getStatusCode(), $response->headers->all());
    }
開發者ID:symfony,項目名稱:symfony,代碼行數:16,代碼來源:Client.php

示例10: sendContent

 /**
  * Allow Tlog to write log stuff in the fina content.
  *
  * @see \Thelia\Core\HttpFoundation\Response::sendContent()
  */
 public function sendContent()
 {
     Tlog::getInstance()->write($this->content);
     parent::sendContent();
 }
開發者ID:margery,項目名稱:thelia,代碼行數:10,代碼來源:Response.php

示例11: mapResponse

 /**
  * Convert Symfony\Component\HttpFoundation\Response to React\Http\Response
  *
  * @param ReactResponse $reactResponse
  * @param SymfonyResponse $syResponse
  */
 protected static function mapResponse(ReactResponse $reactResponse, SymfonyResponse $syResponse)
 {
     $headers = $syResponse->headers->all();
     $reactResponse->writeHead($syResponse->getStatusCode(), $headers);
     // @TODO convert StreamedResponse in an async manner
     if ($syResponse instanceof SymfonyStreamedResponse) {
         ob_start();
         $syResponse->sendContent();
         $content = ob_get_contents();
         ob_end_clean();
     } else {
         $content = $syResponse->getContent();
     }
     $reactResponse->end($content);
 }
開發者ID:nghenglim,項目名稱:php-pm-httpkernel,代碼行數:21,代碼來源:HttpKernel.php

示例12: download

 /**
  * 
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function download()
 {
     $response = new Response($this->_data, 200, array('Content-Type' => 'text/plain', 'Content-Disposition' => 'attachment; filename="' . $this->getFilename() . '"'));
     $response->sendHeaders();
     $response->sendContent();
     $this->_incrementFileIndex();
     return $response;
 }
開發者ID:defan-marunchak,項目名稱:eurotax,代碼行數:12,代碼來源:TransDeb.php

示例13: handleBackupAction

 /**
  * Handle and execute backup of connection
  *
  * @Route("/backup/{key}", name="handleBackup")
  *
  * @param int     $key          key of connected device
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handleBackupAction($key)
 {
     $dataClass = $this->get('DataModel');
     $params = array('key' => $key, 'filter' => '');
     $res = $dataClass->handle('backup', $params, false);
     $resp = new Response();
     $resp->setStatusCode(200);
     $resp->headers->set('Cache-Control', 'private');
     $resp->headers->set('Content-Length', strlen($res));
     $resp->headers->set('Content-Type', 'application/force-download');
     $resp->headers->set('Content-Disposition', sprintf('attachment; filename="%s-%s.xml"', date("Y-m-d"), $dataClass->getHostFromKey($key)));
     $resp->sendHeaders();
     $resp->setContent($res);
     $resp->sendContent();
     die;
 }
開發者ID:Barathi07,項目名稱:Netopeer-GUI,代碼行數:24,代碼來源:DefaultController.php


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