Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preventing call to undefined method isSent #13821

Closed
wants to merge 5 commits into from
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions phalcon/mvc/micro.zep
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ class Micro extends Injectable implements \ArrayAccess
let response = <ResponseInterface> dependencyInjector->getShared("response");
if !response->isSent() {
response->setContent(returnedValue);
response->send();
this->sendIfUnsent(response);
}
}

Expand All @@ -1008,17 +1008,27 @@ class Micro extends Injectable implements \ArrayAccess
*/
if typeof returnedValue == "object" {
if returnedValue instanceof ResponseInterface {
/**
* Automatically send the response
*/
if !returnedValue->isSent() {
returnedValue->send();
}
this->sendIfUnsent(returnedValue);
sergeyklay marked this conversation as resolved.
Show resolved Hide resolved
}
}

return returnedValue;
}

/**
* Prevents isSent from being called on implementations that don't have it
**/
private function sendIfUnsent(<ResponseInterface> response)
{
if method_exists(response, "isSent") {
/**
* Automatically send the response
*/
if !response->isSent() {
response->send();
}
}
}

/**
* Stops the middleware execution avoiding than other middlewares be executed
Expand Down