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


PHP StreamedResponse::create方法代码示例

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


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

示例1: exportAction

 /**
  * Export all plugins
  *
  * @return Response Exportation file
  */
 public function exportAction()
 {
     /**
      * @var Plugin $plugin
      */
     $plugin = $this->get('elcodi.manager.plugin')->getPlugin('Elcodi\\Plugin\\ProductCsvBundle');
     if (!$plugin->isUsable()) {
         $this->createNotFoundException($this->get('translator')->trans('product_csv_plugin.error.is_disabled'));
     }
     /**
      * @var ProductExporter $exporter
      */
     $exporter = $this->get('elcodi_plugin.product_csv.exporter');
     $repository = $this->get('elcodi.repository.product');
     $response = StreamedResponse::create();
     $response->setCallback(function () use($repository, $exporter) {
         $rows = $repository->findAll();
         $exporter->export($rows);
     });
     $configuration = $plugin->getConfiguration();
     $filename = $configuration['export_filename'];
     if (empty($filename)) {
         $filename = 'products.csv';
     }
     return $this->makeDownloadable($response, $filename, 'text/csv');
 }
开发者ID:axelvnk,项目名称:bamboo,代码行数:31,代码来源:CsvController.php

示例2: runLegacyScript

 /**
  * @param $requestPath
  * @param $legacyScript
  *
  * @return \Symfony\Component\HttpFoundation\StreamedResponse
  */
 public function runLegacyScript($requestPath, $legacyScript)
 {
     $container = $this->container;
     $prepend = $this->prependScript;
     $append = $this->appendScript;
     $requireLegacyScript = function () use($requestPath, $legacyScript, $container, $prepend, $append) {
         $_SERVER['PHP_SELF'] = $requestPath;
         $_SERVER['SCRIPT_NAME'] = $requestPath;
         $_SERVER['SCRIPT_FILENAME'] = $legacyScript;
         $_SERVER['SYMFONY_CONTAINER'] = $container;
         chdir(dirname($legacyScript));
         if ($prepend) {
             /** @noinspection PhpIncludeInspection */
             require $prepend;
         }
         /** @noinspection PhpIncludeInspection */
         require $legacyScript;
         if ($append) {
             /** @noinspection PhpIncludeInspection */
             require $append;
         }
     };
     return StreamedResponse::create($requireLegacyScript);
 }
开发者ID:basster,项目名称:legacy-bridge-bundle,代码行数:30,代码来源:LegacyScriptController.php

示例3: testCreate

 public function testCreate()
 {
     $response = StreamedResponse::create(function () {
     }, 204);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\StreamedResponse', $response);
     $this->assertEquals(204, $response->getStatusCode());
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:7,代码来源:StreamedResponseTest.php


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