Skip to content

Commit

Permalink
Merge pull request #7 from continuousphp/master
Browse files Browse the repository at this point in the history
  • Loading branch information
jguittard committed Jun 27, 2015
2 parents 815de0e + fa1f559 commit dcc10cf
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Service/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,16 @@ public function fetch($id)

$api_response_info = curl_getinfo($this->curl);

$result = json_decode($result);
$result = json_decode($result, true);
curl_close($this->curl);

$entityClass = $this->getEntityClass();
$entityName = $this->getEntityName();
return $result->$entityName;
$entity = new $entityClass;
$data = $result[$entityName];
$entity = $this->getHydrator()->hydrate($data, $entity);

return $entity;
}

/**
Expand All @@ -232,7 +237,7 @@ public function create($data)


$response = curl_exec($this->curl);
$result = json_decode($response);
$result = json_decode($response, true);
$api_response_info = curl_getinfo($this->curl);
curl_close($this->curl);

Expand All @@ -241,8 +246,7 @@ public function create($data)
$entityClass = $this->getEntityClass();
$entityName = $this->getEntityName();
$entity = new $entityClass;
$result = $result->$entityName;
$data = (array)$result;
$data = $result[$entityName];
$entity = $this->getHydrator()->hydrate($data, $entity);
return $entity;
}
Expand Down

0 comments on commit dcc10cf

Please sign in to comment.