Last active
August 29, 2015 14:11
-
-
Save bramstroker/619a801ded18996dc59c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyResource extends AbstractResourceListener implements ResourceInterface | |
{ | |
public function fetch($id) | |
{ | |
$entity = $this->getEntityById($id, false); | |
if ($entity === null) { | |
return new ApiProblemResponse(new ApiProblem(404, 'Entity with ID ' . $id . ' not found')); | |
} | |
return $entity; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case 'get': | |
$id = $this->getIdentifier($routeMatch, $request); | |
if ($id !== false) { | |
$action = 'get'; | |
$return = $this->get($id); | |
break; | |
} | |
$action = 'getList'; | |
$return = $this->getList(); | |
break; | |
// HEAD | |
case 'head': | |
$id = $this->getIdentifier($routeMatch, $request); | |
if ($id === false) { | |
$id = null; | |
} | |
$action = 'head'; | |
$this->head($id); | |
$response = $e->getResponse(); | |
$response->setContent(''); | |
$return = $response; | |
break; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment