Last active
April 14, 2016 08:56
-
-
Save eimihar/12e2bb8826769676258837a1d5b7322f to your computer and use it in GitHub Desktop.
method invocation on property accessed through getter
This file contains hidden or 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 on accessing the data by given fields | |
GET /api/person/10?fields=name,address,phone,delete | |
// api function | |
$person = Entity\Person::find($id); | |
if(!isset($_GET['fields'])) | |
return $person->toArray(); | |
$fields = explode(',', $_GET['fields']); | |
$data = array(); | |
// delete method gets invoked. | |
foreach($fields as $field) | |
$data->$field = $person; | |
return $data; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment