Implement Item->getJson();
This commit is contained in:
parent
da43b49abf
commit
2cc6c7d0ee
17
main.php
17
main.php
|
@ -41,7 +41,7 @@ function get_item()
|
|||
Json::error('No item was found with the given ID')->die();
|
||||
}
|
||||
|
||||
return Json::new($item->getUri());
|
||||
return $item->getJson();
|
||||
}
|
||||
|
||||
function post_item()
|
||||
|
@ -49,11 +49,7 @@ function post_item()
|
|||
// The checks are performed internally
|
||||
$item = Item::upload($_FILES['file']);
|
||||
|
||||
return Json::new([
|
||||
'type' => 'success',
|
||||
'id' => $item->getHash(),
|
||||
'link' => $item->getUri(),
|
||||
]);
|
||||
return $item->getJson();
|
||||
};
|
||||
|
||||
class MediaDB
|
||||
|
@ -237,6 +233,15 @@ class Item
|
|||
$this->extension,
|
||||
);
|
||||
}
|
||||
|
||||
public function getJson(): Json
|
||||
{
|
||||
return Json::new([
|
||||
'id' => $this->hash,
|
||||
'link' => $this->getUri(),
|
||||
'tags' => $this->tags,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
class Json
|
||||
|
|
Loading…
Reference in New Issue