Skip to content

Instantly share code, notes, and snippets.

@pandurx
Created April 12, 2018 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandurx/ef2eb4163b38a191dda81346f3cba3a3 to your computer and use it in GitHub Desktop.
Save pandurx/ef2eb4163b38a191dda81346f3cba3a3 to your computer and use it in GitHub Desktop.
// 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