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

added a condition in the find method to handle http 500 requests. Also, ... #1

Merged
merged 1 commit into from
Nov 11, 2013
Merged
Changes from all 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
13 changes: 9 additions & 4 deletions src/Indatus/ActiveResource/ActiveResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,15 +949,20 @@ public static function find($id, $getParams = array())
//handle error saving
$request->getEventDispatcher()->addListener(
'request.error',
function (\Guzzle\Common\Event $event) {

//instance must be passed by reference since it's in a call back
function (\Guzzle\Common\Event $event) use (&$instance) {
if ($event['response']->getStatusCode() == 404) {

// Stop other events from firing
$event->stopPropagation();

//not found
$instance = false;

} else if($event['response']->getStatusCode() == 500) {

$event->stopPropagation();
//not found
$instance = false;
}
}
);
Expand All @@ -971,7 +976,7 @@ function (\Guzzle\Common\Event $event) {

//send the request
$response = self::sendRequest($request);

if ($response->getStatusCode() == 404 || $instance === false) {
return null;
}
Expand Down