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


PHP Response::getFile方法代码示例

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


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

示例1: getStream

 /**
  * Get the stream for the new response.
  *
  * @param \Cake\Network\Response $response The cake response to extract the body from.
  * @return \Psr\Http\Message\StreamInterface|string The stream.
  */
 protected static function getStream($response)
 {
     $stream = 'php://memory';
     $body = $response->body();
     if (is_string($body) && strlen($body)) {
         $stream = new Stream('php://memory', 'wb');
         $stream->write($body);
         return $stream;
     }
     if (is_callable($body)) {
         $stream = new CallbackStream($body);
         return $stream;
     }
     $file = $response->getFile();
     if ($file) {
         $stream = new Stream($file->path, 'rb');
         return $stream;
     }
     return $stream;
 }
开发者ID:nrother,项目名称:cakephp,代码行数:26,代码来源:ResponseTransformer.php

示例2: testGetFile

 /**
  * test getFile method
  *
  * @return void
  */
 public function testGetFile()
 {
     $response = new Response();
     $this->assertNull($response->getFile(), 'No file to get');
     $response->file(TEST_APP . 'vendor/css/test_asset.css');
     $file = $response->getFile();
     $this->assertInstanceOf('Cake\\Filesystem\\File', $file, 'Should get a file');
     $this->assertPathEquals(TEST_APP . 'vendor' . DS . 'css' . DS . 'test_asset.css', $file->path);
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:14,代码来源:ResponseTest.php

示例3: assertFileResponse

 /**
  * Asserts that a file with the given name was sent in the response
  *
  * @param string $expected The file name that should be sent in the response
  * @param string $message The failure message that will be appended to the generated message.
  * @return void
  */
 public function assertFileResponse($expected, $message = '')
 {
     if ($this->_response === null) {
         $this->fail('No response set, cannot assert file.');
     }
     $actual = isset($this->_response->getFile()->path) ? $this->_response->getFile()->path : null;
     if ($actual === null) {
         $this->fail('No file was sent in this response');
     }
     $this->assertEquals($expected, $actual, $message);
 }
开发者ID:aceat64,项目名称:cakephp,代码行数:18,代码来源:IntegrationTestCase.php


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