mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-14 05:13:46 +02:00
The PR is a huge refactor of all Reflect and Vegvisir code. I've merged the API and "Front-end" codebases together into the same root, this will allow for both Reflect and Vegvisir to use the same resources. Not only that, but I've also added proper database modeling with actual OOP inheritance for database tables. Reviewed-on: https://codeberg.org/vlw/vlw.se/pulls/23
51 lines
No EOL
1.4 KiB
PHP
51 lines
No EOL
1.4 KiB
PHP
<?php
|
|
|
|
namespace VLW\Database\Models\Work;
|
|
|
|
use \VV;
|
|
|
|
use VLW\API\Endpoints;
|
|
use VLW\Database\Models\Model;
|
|
use VLW\Database\Models\Work\Work;
|
|
use VLW\Database\Tables\Work\ActionsTable;
|
|
|
|
require_once VV::root("src/API/Endpoints.php");
|
|
require_once VV::root("src/Database/Models/Model.php");
|
|
require_once VV::root("src/Database/Models/Work/Work.php");
|
|
require_once VV::root("src/Database/Tables/Work/Actions.php");
|
|
|
|
class Action extends Model {
|
|
public function __construct() {
|
|
parent::__construct();
|
|
}
|
|
|
|
public static function all(array $params = []): array {
|
|
return array_map(fn(array $item): Action => (new Action())->assign($item), parent::list(Endpoints::WORK_ACTIONS, $params));
|
|
}
|
|
|
|
public static function from(Work $work): array {
|
|
return self::all([
|
|
ActionsTable::REF_WORK_ID->value => $work->id
|
|
]);
|
|
}
|
|
|
|
public function icon_prepended(): ?string {
|
|
return $this->get(ActionsTable::ICON_PREPENDED->value);
|
|
}
|
|
|
|
public function icon_appended(): ?string {
|
|
return $this->get(ActionsTable::ICON_APPENDED->value);
|
|
}
|
|
|
|
public function display_text(): string {
|
|
return $this->get(ActionsTable::DISPLAY_TEXT->value);
|
|
}
|
|
|
|
public function href(): ?string {
|
|
return $this->get(ActionsTable::HREF->value);
|
|
}
|
|
|
|
public function classes(): array {
|
|
return $this->get(ActionsTable::CLASS_LIST->value) ? explode(",", $this->get(ActionsTable::CLASS_LIST->value)) : [];
|
|
}
|
|
} |