mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 13:03:41 +02:00
28 lines
No EOL
731 B
PHP
28 lines
No EOL
731 B
PHP
<?php
|
|
|
|
use Reflect\{Response, Path};
|
|
|
|
use VLW\API\API;
|
|
use VLW\Database\Models\Work\{Work, Tag};
|
|
|
|
require_once Path::root("src/API/API.php");
|
|
require_once Path::root("src/Database/Models/Work/Tag.php");
|
|
require_once Path::root("src/Database/Models/Work/Work.php");
|
|
|
|
final class GET_Work extends API {
|
|
private static function entity(Work $work): object {
|
|
return (object) [
|
|
"tags" => array_map(fn(Tag $tag): string => $tag->label->name, Tag::from($work)),
|
|
"actions" => [],
|
|
"details" => $work
|
|
];
|
|
}
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
}
|
|
|
|
public function main(): Response {
|
|
return new Response(array_map(fn(Work $work): object => self::entity($work), Work::all()));
|
|
}
|
|
} |