Skip to content

Commit

Permalink
Slimplify functions down as per Tim's review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed Jun 8, 2019
1 parent 46dddc5 commit 90f6c8d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
3 changes: 1 addition & 2 deletions CRM/Utils/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -1867,8 +1867,7 @@ public static function createDefaultCrudLink($crudLinkSpec) {
* @param \Psr\Http\Message\ResponseInterface $response
*/
public static function sendResponse(\Psr\Http\Message\ResponseInterface $response) {
$config = CRM_Core_Config::singleton();
$config->userSystem->sendResponse($response);
$config = CRM_Core_Config::singleton()->userSystem->sendResponse($response);
}

}
7 changes: 2 additions & 5 deletions CRM/Utils/System/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -955,12 +955,9 @@ public function sendResponse(\Psr\Http\Message\ResponseInterface $response) {
// PHP 5.4+
http_response_code($response->getStatusCode());
}
else {
// @todo should we remove this given we are no longer supporting < PHP 5.6 however keeping
// in for the moment for compatability with the original AssetBuilder code.
header('X-PHP-Response-Code: ' . $response->getStatusCode(), TRUE, $reponse->getStatusCode());
foreach ($response->getHeaders() as $name => $values) {
CRM_Utils_System::setHttpHeader($name, implode(', ', (array) $values));
}
CRM_Utils_System::setHttpHeader('Content-Type', $response->getHeaderLine('Content-Type'));
echo $response->getBody();
CRM_Utils_System::civiExit();
}
Expand Down
11 changes: 2 additions & 9 deletions CRM/Utils/System/WordPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,16 +871,9 @@ public function synchronizeUsers() {
public function sendResponse(\Psr\Http\Message\ResponseInterface $response) {
// use WordPress function status_header to ensure 404 response is sent
status_header($response->getStatusCode());
if (function_exists('http_response_code')) {
// PHP 5.4+
http_response_code($response->getStatusCode());
foreach ($response->getHeaders() as $name => $values) {
CRM_Utils_System::setHttpHeader($name, implode(', ', (array) $values));
}
else {
// @todo should we remove this given we are no longer supporting < PHP 5.6 however keeping
// in for the moment for compatability with the original AssetBuilder code.
header('X-PHP-Response-Code: ' . $response->getStatusCode(), TRUE, $response->getStatusCode());
}
CRM_Utils_System::setHttpHeader('Content-Type', $response->getHeaderLine('Content-Type'));
echo $response->getBody();
CRM_Utils_System::civiExit();
}
Expand Down

0 comments on commit 90f6c8d

Please sign in to comment.