Skip to content

Commit eb96bf0

Browse files
authored
Merge pull request #6 from nickygerritsen/set-response
Set response back on controller
2 parents 8e7aa45 + 760fddd commit eb96bf0

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/Panel/ClientCallPanel.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,24 @@ public function shutdown(Event $event)
9999
*/
100100
$controller = $event->getSubject();
101101
if ($controller instanceof RequestsController) {
102-
$this->_injectScriptsAndStyles($controller->getResponse());
102+
$controller->setResponse($this->_injectScriptsAndStyles($controller->getResponse()));
103103
}
104104
}
105105

106106
/**
107-
* Injects the JS to build the toolbar.
107+
* Injects the JS to build the toolbar and return the new response.
108108
*
109109
* The toolbar will only be injected if the response's content type
110110
* contains HTML and there is a </body> tag.
111111
*
112112
* @param \Cake\Network\Response $response The response to augment.
113113
*
114-
* @return void
114+
* @return \Cake\Network\Response
115115
*/
116116
protected function _injectScriptsAndStyles($response)
117117
{
118118
if (strpos($response->getType(), 'html') === false) {
119-
return;
119+
return $response;
120120
}
121121
$body = $response->getBody();
122122

@@ -136,6 +136,6 @@ protected function _injectScriptsAndStyles($response)
136136
$body = substr($body, 0, $pos) . $style . substr($body, $pos);
137137
}
138138

139-
$response = $response->withStringBody($body);
139+
return $response->withStringBody($body);
140140
}
141141
}

0 commit comments

Comments
 (0)