Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-foundation/StreamedResponse.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
29 protected $callback; | 29 protected $callback; |
30 protected $streamed; | 30 protected $streamed; |
31 private $headersSent; | 31 private $headersSent; |
32 | 32 |
33 /** | 33 /** |
34 * Constructor. | |
35 * | |
36 * @param callable|null $callback A valid PHP callback or null to set it later | 34 * @param callable|null $callback A valid PHP callback or null to set it later |
37 * @param int $status The response status code | 35 * @param int $status The response status code |
38 * @param array $headers An array of response headers | 36 * @param array $headers An array of response headers |
39 */ | 37 */ |
40 public function __construct(callable $callback = null, $status = 200, $headers = array()) | 38 public function __construct(callable $callback = null, $status = 200, $headers = array()) |
64 | 62 |
65 /** | 63 /** |
66 * Sets the PHP callback associated with this Response. | 64 * Sets the PHP callback associated with this Response. |
67 * | 65 * |
68 * @param callable $callback A valid PHP callback | 66 * @param callable $callback A valid PHP callback |
67 * | |
68 * @return $this | |
69 */ | 69 */ |
70 public function setCallback(callable $callback) | 70 public function setCallback(callable $callback) |
71 { | 71 { |
72 $this->callback = $callback; | 72 $this->callback = $callback; |
73 | |
74 return $this; | |
73 } | 75 } |
74 | 76 |
75 /** | 77 /** |
76 * {@inheritdoc} | 78 * {@inheritdoc} |
77 * | 79 * |
78 * This method only sends the headers once. | 80 * This method only sends the headers once. |
81 * | |
82 * @return $this | |
79 */ | 83 */ |
80 public function sendHeaders() | 84 public function sendHeaders() |
81 { | 85 { |
82 if ($this->headersSent) { | 86 if ($this->headersSent) { |
83 return; | 87 return $this; |
84 } | 88 } |
85 | 89 |
86 $this->headersSent = true; | 90 $this->headersSent = true; |
87 | 91 |
88 parent::sendHeaders(); | 92 return parent::sendHeaders(); |
89 } | 93 } |
90 | 94 |
91 /** | 95 /** |
92 * {@inheritdoc} | 96 * {@inheritdoc} |
93 * | 97 * |
94 * This method only sends the content once. | 98 * This method only sends the content once. |
99 * | |
100 * @return $this | |
95 */ | 101 */ |
96 public function sendContent() | 102 public function sendContent() |
97 { | 103 { |
98 if ($this->streamed) { | 104 if ($this->streamed) { |
99 return; | 105 return $this; |
100 } | 106 } |
101 | 107 |
102 $this->streamed = true; | 108 $this->streamed = true; |
103 | 109 |
104 if (null === $this->callback) { | 110 if (null === $this->callback) { |
105 throw new \LogicException('The Response callback must not be null.'); | 111 throw new \LogicException('The Response callback must not be null.'); |
106 } | 112 } |
107 | 113 |
108 call_user_func($this->callback); | 114 call_user_func($this->callback); |
115 | |
116 return $this; | |
109 } | 117 } |
110 | 118 |
111 /** | 119 /** |
112 * {@inheritdoc} | 120 * {@inheritdoc} |
113 * | 121 * |
114 * @throws \LogicException when the content is not null | 122 * @throws \LogicException when the content is not null |
123 * | |
124 * @return $this | |
115 */ | 125 */ |
116 public function setContent($content) | 126 public function setContent($content) |
117 { | 127 { |
118 if (null !== $content) { | 128 if (null !== $content) { |
119 throw new \LogicException('The content cannot be set on a StreamedResponse instance.'); | 129 throw new \LogicException('The content cannot be set on a StreamedResponse instance.'); |
120 } | 130 } |
131 | |
132 return $this; | |
121 } | 133 } |
122 | 134 |
123 /** | 135 /** |
124 * {@inheritdoc} | 136 * {@inheritdoc} |
125 * | 137 * |