Elgg  Version 3.0
entity.php
Go to the documentation of this file.
1 <?php
2 
3 $entity = elgg_extract('entity', $vars);
4 if (!$entity instanceof ElggEntity) {
5  return;
6 }
7 
8 $type = $entity->getType();
9 $subtype = $entity->getSubtype();
10 
11 $views = [
12  "search/$type/$subtype",
13  "search/$type/default",
14 ];
15 
16 foreach ($views as $view) {
17  if (elgg_view_exists($view)) {
18  echo elgg_view($view, $vars);
19  return;
20  }
21 }
22 
23 echo json_encode($entity->toObject());
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:205
$views
Definition: entity.php:11
$subtype
Definition: entity.php:9
$entity
Definition: entity.php:3
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) if(!$owner->saveIconFromElggFile($owner->getIcon('master'), 'icon', $coords)) $view
Definition: crop.php:30
elgg echo
Translates a string.
Definition: languages.js:43
if(!$entity instanceof ElggEntity) $type
Definition: entity.php:8
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$vars['type']
Definition: save.php:11
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246