Created
April 12, 2018 20:39
-
-
Save pandurx/ef2eb4163b38a191dda81346f3cba3a3 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
// api expose function calls | |
elgg_ws_expose_function( | |
'get.entity_list', | |
'get_entity_list', | |
[ | |
'type' => [ | |
'type' => 'string', | |
'required' => true, | |
'description' => 'the type of entity in string format', | |
], | |
'subtype' => [ | |
'type' => 'string', | |
'required' => false, | |
'description' => 'the subtype of entity in string format, not required', | |
], | |
], | |
'retrieves all entities filtered by type [and subtype]', | |
'GET', | |
false, | |
false | |
); | |
} | |
// api calls | |
function get_entity_list($type, $subtype) { | |
$entities = elgg_get_entities(array( | |
'type' => $type, | |
'subtype' => $subtype, | |
'limit' => 15 | |
)); | |
foreach ($entities as $entity) { | |
$title_array = json_decode($entity->title, true); | |
$description_array = json_decode($entity->description, true); | |
$arr[] = array( | |
'guid' => $entity->getGUID(), | |
'title' => $title_array, | |
'description' => $description_array, | |
'type' => $entity->getType(), | |
'subtype' => $entity->getSubtype(), | |
'access_id' => $entity->access_id | |
); | |
} | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment