Skip to content

Commit c930932

Browse files
committed
Change signature of render() method to receive HttpResponseInterface
1 parent 2084f2e commit c930932

File tree

9 files changed

+31
-93
lines changed

9 files changed

+31
-93
lines changed

app/code/Magento/Backend/Model/View/Result/Redirect.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Backend\Model\UrlInterface;
1111
use Magento\Framework\App;
1212
use Magento\Framework\App\ActionFlag;
13+
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
1314

1415
class Redirect extends \Magento\Framework\Controller\Result\Redirect
1516
{
@@ -56,7 +57,7 @@ public function setRefererOrBaseUrl()
5657
/**
5758
* {@inheritdoc}
5859
*/
59-
protected function render(App\ResponseInterface $response)
60+
protected function render(HttpResponseInterface $response)
6061
{
6162
$this->session->setIsUrlNotice($this->actionFlag->get('', AbstractAction::FLAG_IS_URLS_CHECKED));
6263
return parent::render($response);

lib/internal/Magento/Framework/Controller/AbstractResult.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ protected function applyHttpHeaders(HttpResponseInterface $response)
108108
}
109109

110110
/**
111-
* @param ResponseInterface $response
111+
* @param HttpResponseInterface $response
112112
* @return $this
113113
*/
114-
abstract protected function render(ResponseInterface $response);
114+
abstract protected function render(HttpResponseInterface $response);
115115

116116
/**
117117
* Render content

lib/internal/Magento/Framework/Controller/Result/Forward.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Magento\Framework\Controller\Result;
88

99
use Magento\Framework\App\RequestInterface;
10-
use Magento\Framework\App\ResponseInterface;
10+
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
1111
use Magento\Framework\Controller\AbstractResult;
1212

1313
class Forward extends AbstractResult
@@ -99,7 +99,7 @@ public function forward($action)
9999
/**
100100
* {@inheritdoc}
101101
*/
102-
protected function render(ResponseInterface $response)
102+
protected function render(HttpResponseInterface $response)
103103
{
104104
return $this;
105105
}

lib/internal/Magento/Framework/Controller/Result/Json.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
namespace Magento\Framework\Controller\Result;
88

9-
use Magento\Framework\App\Response\Http as HttpResponse;
10-
use Magento\Framework\App\ResponseInterface;
9+
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
1110
use Magento\Framework\Controller\AbstractResult;
1211
use Magento\Framework\Translate\InlineInterface;
1312

@@ -60,22 +59,13 @@ public function setJsonData($jsonData)
6059
}
6160

6261
/**
63-
* @param HttpResponse|ResponseInterface $response
64-
* @return $this
65-
*/
66-
protected function render(ResponseInterface $response)
67-
{
68-
return $this->renderHttpResponse($response);
69-
}
70-
71-
/**
72-
* @param HttpResponse $response
73-
* @return $this
62+
* {@inheritdoc}
7463
*/
75-
private function renderHttpResponse(HttpResponse $response)
64+
protected function render(HttpResponseInterface $response)
7665
{
7766
$this->translateInline->processResponseBody($this->json, true);
78-
$response->representJson($this->json);
67+
$response->setHeader('Content-Type', 'application/json', true);
68+
$response->setBody($this->json);
7969
return $this;
8070
}
8171
}

lib/internal/Magento/Framework/Controller/Result/Raw.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace Magento\Framework\Controller\Result;
88

99
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
10-
use Magento\Framework\App\ResponseInterface;
1110
use Magento\Framework\Controller\AbstractResult;
1211

1312
/**
@@ -32,21 +31,11 @@ public function setContents($contents)
3231
}
3332

3433
/**
35-
* @param HttpResponseInterface|ResponseInterface $response
36-
* @return $this
37-
*/
38-
protected function render(ResponseInterface $response)
39-
{
40-
return $this->renderHttpResponse($response);
41-
}
42-
43-
/**
44-
* @param HttpResponseInterface $httpResponse
45-
* @return $this
34+
* {@inheritdoc}
4635
*/
47-
private function renderHttpResponse(HttpResponseInterface $httpResponse)
36+
protected function render(HttpResponseInterface $response)
4837
{
49-
$httpResponse->setBody($this->contents);
38+
$response->setBody($this->contents);
5039
return $this;
5140
}
5241
}

lib/internal/Magento/Framework/Controller/Result/Redirect.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use Magento\Framework\App;
1010
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
11-
use Magento\Framework\App\ResponseInterface;
1211
use Magento\Framework\Controller\AbstractResult;
1312

1413
/**
@@ -92,21 +91,11 @@ public function setPath($path, array $params = [])
9291
}
9392

9493
/**
95-
* @param HttpResponseInterface|ResponseInterface $response
96-
* @return $this
97-
*/
98-
protected function render(ResponseInterface $response)
99-
{
100-
return $this->renderHttpResponse($response);
101-
}
102-
103-
/**
104-
* @param HttpResponseInterface $httpResponse
105-
* @return $this
94+
* {@inheritdoc}
10695
*/
107-
private function renderHttpResponse(HttpResponseInterface $httpResponse)
96+
protected function render(HttpResponseInterface $response)
10897
{
109-
$httpResponse->setRedirect($this->url);
98+
$response->setRedirect($this->url);
11099
return $this;
111100
}
112101
}

lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ public function testRenderResult()
2424
/** @var \Magento\Framework\Translate\InlineInterface|\PHPUnit_Framework_MockObject_MockObject
2525
* $translateInline
2626
*/
27-
$translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class, [], [], '', false);
27+
$translateInline = $this->getMock(\Magento\Framework\Translate\InlineInterface::class);
2828
$translateInline->expects($this->any())->method('processResponseBody')->with($json, true)->will(
2929
$this->returnValue($translatedJson)
3030
);
3131

32-
$response = $this->getMock(\Magento\Framework\App\Response\Http::class, ['representJson'], [], '', false);
33-
$response->expects($this->atLeastOnce())->method('representJson')->with($json)->will($this->returnSelf());
32+
$response = $this->getMock(\Magento\Framework\App\Response\HttpInterface::class);
33+
$response->expects($this->atLeastOnce())->method('setHeader')->with('Content-Type', 'application/json', true);
34+
$response->expects($this->atLeastOnce())->method('setBody')->with($json);
3435

3536
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
3637
$resultJson = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))

lib/internal/Magento/Framework/View/Result/Layout.php

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function initLayoutBuilder()
102102
/**
103103
* Get layout instance for current page
104104
*
105-
* @return \Magento\Framework\View\Layout
105+
* @return \Magento\Framework\View\LayoutInterface
106106
*/
107107
public function getLayout()
108108
{
@@ -153,19 +153,10 @@ public function addUpdate($update)
153153
/**
154154
* Render current layout
155155
*
156-
* @param HttpResponseInterface|ResponseInterface $response
156+
* @param HttpResponseInterface|ResponseInterface $httpResponse
157157
* @return $this
158158
*/
159-
public function renderResult(ResponseInterface $response)
160-
{
161-
return $this->renderHttpResult($response);
162-
}
163-
164-
/**
165-
* @param HttpResponseInterface $httpResponse
166-
* @return $this
167-
*/
168-
private function renderHttpResult(HttpResponseInterface $httpResponse)
159+
public function renderResult(ResponseInterface $httpResponse)
169160
{
170161
\Magento\Framework\Profiler::start('LAYOUT');
171162
\Magento\Framework\Profiler::start('layout_render');
@@ -182,25 +173,13 @@ private function renderHttpResult(HttpResponseInterface $httpResponse)
182173
}
183174

184175
/**
185-
* Render current layout
186-
*
187-
* @param HttpResponseInterface|ResponseInterface $response
188-
* @return $this
189-
*/
190-
protected function render(ResponseInterface $response)
191-
{
192-
return $this->renderHttpResponse($response);
193-
}
194-
195-
/**
196-
* @param HttpResponseInterface $httpResponse
197-
* @return $this
176+
* {@inheritdoc}
198177
*/
199-
private function renderHttpResponse(HttpResponseInterface $httpResponse)
178+
protected function render(HttpResponseInterface $response)
200179
{
201180
$output = $this->layout->getOutput();
202181
$this->translateInline->processResponseBody($output);
203-
$httpResponse->appendBody($output);
182+
$response->appendBody($output);
204183
return $this;
205184
}
206185
}

lib/internal/Magento/Framework/View/Result/Page.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use Magento\Framework;
1010
use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
11-
use Magento\Framework\App\ResponseInterface;
1211
use Magento\Framework\View;
1312

1413
/**
@@ -220,19 +219,9 @@ public function addPageLayoutHandles(array $parameters = [], $defaultHandle = nu
220219
}
221220

222221
/**
223-
* @param HttpResponseInterface|ResponseInterface $response
224-
* @return $this
225-
*/
226-
protected function render(ResponseInterface $response)
227-
{
228-
return $this->renderHttpResponse($response);
229-
}
230-
231-
/**
232-
* @param HttpResponseInterface $httpResponse
233-
* @return $this
222+
* {@inheritdoc}
234223
*/
235-
private function renderHttpResponse(HttpResponseInterface $httpResponse)
224+
protected function render(HttpResponseInterface $response)
236225
{
237226
$this->pageConfig->publicBuild();
238227
if ($this->getPageLayout()) {
@@ -254,9 +243,9 @@ private function renderHttpResponse(HttpResponseInterface $httpResponse)
254243
$this->assign('layoutContent', $output);
255244
$output = $this->renderPage();
256245
$this->translateInline->processResponseBody($output);
257-
$httpResponse->appendBody($output);
246+
$response->appendBody($output);
258247
} else {
259-
parent::render($httpResponse);
248+
parent::render($response);
260249
}
261250
return $this;
262251
}

0 commit comments

Comments
 (0)