minor #24374 [HttpFoundation] Return instance in StreamedResponse (abellion)
This PR was squashed before being merged into the 3.4 branch (closes #24374).
Discussion
----------
[HttpFoundation] Return instance in StreamedResponse
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| License | MIT
<!--
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the 3.4,
legacy code removals go to the master branch.
- Please fill in this template according to the PR you're about to submit.
- Replace this comment by a description of what your PR is solving.
-->
Commits
-------
2080582a75
[HttpFoundation] Return instance in StreamedResponse
This commit is contained in:
commit
77998813fe
@ -66,16 +66,22 @@ class StreamedResponse extends Response
|
|||||||
* Sets the PHP callback associated with this Response.
|
* Sets the PHP callback associated with this Response.
|
||||||
*
|
*
|
||||||
* @param callable $callback A valid PHP callback
|
* @param callable $callback A valid PHP callback
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCallback(callable $callback)
|
public function setCallback(callable $callback)
|
||||||
{
|
{
|
||||||
$this->callback = $callback;
|
$this->callback = $callback;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* This method only sends the headers once.
|
* This method only sends the headers once.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function sendHeaders()
|
public function sendHeaders()
|
||||||
{
|
{
|
||||||
@ -85,13 +91,15 @@ class StreamedResponse extends Response
|
|||||||
|
|
||||||
$this->headersSent = true;
|
$this->headersSent = true;
|
||||||
|
|
||||||
parent::sendHeaders();
|
return parent::sendHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* This method only sends the content once.
|
* This method only sends the content once.
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function sendContent()
|
public function sendContent()
|
||||||
{
|
{
|
||||||
@ -106,18 +114,24 @@ class StreamedResponse extends Response
|
|||||||
}
|
}
|
||||||
|
|
||||||
call_user_func($this->callback);
|
call_user_func($this->callback);
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @throws \LogicException when the content is not null
|
* @throws \LogicException when the content is not null
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setContent($content)
|
public function setContent($content)
|
||||||
{
|
{
|
||||||
if (null !== $content) {
|
if (null !== $content) {
|
||||||
throw new \LogicException('The content cannot be set on a StreamedResponse instance.');
|
throw new \LogicException('The content cannot be set on a StreamedResponse instance.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user