Elgg  Version master
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());
$entity
Entity view of an item in the trash.
Definition: entity.php:8
if(!$entity instanceof\ElggEntity) $views
Definition: entity.php:13
if(!$entity instanceof ElggEntity) $type
Definition: entity.php:8
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
if(!empty($avatar)&&!$avatar->isValid()) elseif(empty($avatar)) if(!$owner->saveIconFromUploadedFile('avatar')) if(!elgg_trigger_event('profileiconupdate', $owner->type, $owner)) $view
Definition: upload.php:39
$vars
Definition: theme.php:5
elgg_view_exists(string $view, string $viewtype= '', bool $recurse=true)
Returns whether the specified view exists.
Definition: views.php:131
$subtype
Definition: entity.php:9