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


PHP StreamedResponse::prepare方法代码示例

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


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

示例1: testPrepareWithHeadRequest

 public function testPrepareWithHeadRequest()
 {
     $response = new StreamedResponse(function () {
         echo 'foo';
     });
     $request = Request::create('/', 'HEAD');
     $response->prepare($request);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:8,代码来源:StreamedResponseTest.php

示例2: testPrepareWithCacheHeaders

 public function testPrepareWithCacheHeaders()
 {
     $response = new StreamedResponse(function () {
         echo 'foo';
     }, 200, array('Cache-Control' => 'max-age=600, public'));
     $request = Request::create('/', 'GET');
     $response->prepare($request);
     $this->assertEquals('max-age=600, public', $response->headers->get('Cache-Control'));
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:9,代码来源:StreamedResponseTest.php

示例3: testPrepareWith10Protocol

 public function testPrepareWith10Protocol()
 {
     $response = new StreamedResponse(function () {
         echo 'foo';
     });
     $request = Request::create('/');
     $request->server->set('SERVER_PROTOCOL', '1.0');
     $response->prepare($request);
     $this->assertEquals('1.0', $response->getProtocolVersion());
     $this->assertNull($response->headers->get('Transfer-Encoding'));
     $this->assertEquals('no-cache, private', $response->headers->get('Cache-Control'));
 }
开发者ID:neokensou,项目名称:symfony,代码行数:12,代码来源:StreamedResponseTest.php

示例4: exportAllToCSVAction

 /**
  * @Route("/export", name="area_edk_participant_export_all")
  */
 public function exportAllToCSVAction(Request $request)
 {
     $repository = $this->get(self::REPOSITORY_NAME);
     $area = $this->getMembership()->getItem();
     $response = new StreamedResponse(function () use($repository, $area) {
         $repository->exportToCSVStream($this->getTranslator(), $area);
     });
     $response->headers->set('Content-Type', 'text/csv');
     $response->headers->set('Cache-Control', '');
     $response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s'));
     $contentDisposition = $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'participants-all-routes.csv');
     $response->headers->set('Content-Disposition', $contentDisposition);
     $response->prepare($request);
     return $response;
 }
开发者ID:zyxist,项目名称:cantiga,代码行数:18,代码来源:AreaParticipantController.php

示例5: downloadAction

 /**
  * @Route("/file_manager/download", name="spliced_cms_admin_file_manager_download")
  * @Template()
  */
 public function downloadAction()
 {
     $this->loadContext();
     $file = $this->file;
     if (is_null($this->file) || false === $this->file->getRealPath()) {
         $this->get('session')->getFlashBag()->add('error', 'File Not Found');
         return $this->redirect($this->generateUrl('spliced_cms_admin_file_manager', array('dir' => str_replace($this->baseDir->getRealPath(), '', $this->dir->getRealPath()))));
     }
     $file = $this->file;
     $response = new StreamedResponse(function () use($file) {
         echo $file->getContents();
     });
     $info = new \finfo(FILEINFO_MIME_TYPE);
     $response->headers->set('Content-Type', $info->file($file->getRealPath()));
     $response->headers->set('Cache-Control', '');
     $response->headers->set('Content-Length', $file->getSize());
     $response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s'));
     $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $file->getFilename()));
     $response->prepare($this->get('request'));
     return $response;
 }
开发者ID:splicedmedia,项目名称:cms-bundle,代码行数:25,代码来源:FileManagementController.php

示例6: downloadcsvAction

 /**
  * route to download CSV file
  * @param string $slug
  * @param mixed $group
  */
 public function downloadcsvAction($slug, $group = false)
 {
     //$param = $this->getConfiguration($slug, $group);
     $repository = $this->getDoctrine()->getRepository('FgmsSurveyBundle:Questionnaire');
     $sluggroup = $group != false ? $group : '';
     $query = $repository->createQueryBuilder('q')->where('q.slug = :slug AND q.sluggroup = :sluggroup')->setParameters(array('slug' => $slug, 'sluggroup' => $sluggroup))->orderBy('q.createDate', 'ASC')->getQuery();
     $response = new StreamedResponse();
     $response->setCallback(function () use($query) {
         $handle = fopen('php://output', 'w+');
         fputcsv($handle, array('Survey#', 'Date', 'Time', 'Group', 'Property', 'Room', 'Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8', 'Q9', 'Q10', 'Q11', 'Q12', 'Q13', 'Q14', 'Q15'), ',');
         foreach ($query->getResult() as $item) {
             fputcsv($handle, array($item->getId(), $item->getCreateDate()->format('F j, Y'), $item->getCreateDate()->format('h:i A'), $item->getSluggroup(), $item->getSlug(), $item->getRoomNumber(), $item->getQuestion1(), $item->getQuestion2(), $item->getQuestion3(), $item->getQuestion4(), $item->getQuestion5(), $item->getQuestion6(), $item->getQuestion7(), $item->getQuestion8(), $item->getQuestion9(), $item->getQuestion10(), $item->getQuestion11(), $item->getQuestion12(), $item->getQuestion13(), $item->getQuestion14(), $item->getQuestion15()));
         }
         fclose($handle);
     });
     $response->setStatusCode(200);
     $response->headers->set('Content-Type', 'application/force-download');
     $response->headers->set('Content-Type', 'text/csv; charset=utf-8');
     $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $slug . '-export.csv'));
     $response->prepare($this->request);
     return $response;
 }
开发者ID:sturple,项目名称:GuestSurveyBundle,代码行数:27,代码来源:DefaultController.php

示例7: importAction

 public function importAction(Request $request)
 {
     $filepath = $this->checkReportFile($request);
     if ($filepath instanceof Response) {
         return $filepath;
     }
     $filemark = $request->get('filemark');
     $types = array('orders', 'employes', 'calls');
     if (!($type = $request->get('type')) || !in_array($type, $types, true)) {
         return $this->redirect($this->generateUrl('taxi_prize_importer_confirm', array('filemark' => $filemark)));
     }
     // "Переезд" на новый импортер
     if ($type === 'employes') {
         $type = 'employes2';
     }
     $namespace = '\\TaxiPrize\\ImporterBundle\\Import\\Importer\\';
     $importer_class = $namespace . ucfirst($type) . 'Importer';
     $source = new Import\ExcelSource($filepath);
     /** @var Import\AbstractImporter */
     $importer = new $importer_class($source);
     // Checking for header mismatch
     $header_mismatch = $importer->getHeaderMismatch();
     if (!empty($header_mismatch)) {
         return $this->render('TaxiPrizeImporterBundle:Default:import-fail.html.php', array('error_header_mismatch' => $header_mismatch, 'expected_header' => $importer->getExpectedHeader()));
     }
     $controller = $this;
     $callb = function () use($controller, $importer) {
         $controller->importOutput($importer);
     };
     $response = new StreamedResponse($callb);
     return $response->prepare($request);
     //    	return $this->render('TaxiPrizeImporterBundle:Default:import.html.php', array(
     //    			'result' => $result,
     //				'not_imported_file_link' => $not_imported_file_link,
     //    	));
 }
开发者ID:justus-alex,项目名称:TaxiPrize,代码行数:36,代码来源:DefaultController.php


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