mirror of
https://codeberg.org/vlw/vlw.se.git
synced 2025-09-13 21:13:40 +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
40 lines
No EOL
1 KiB
PHP
40 lines
No EOL
1 KiB
PHP
<?php
|
|
|
|
use ReflectRules\Ruleset;
|
|
use Reflect\{Response, Path, Call};
|
|
|
|
use VLW\API\Endpoints;
|
|
use VLW\Database\Database;
|
|
use VLW\Database\Tables\About\LanguagesTable;
|
|
|
|
require_once Path::root("src/API/Endpoints.php");
|
|
require_once Path::root("src/Database/Database.php");
|
|
require_once Path::root("src/Database/Tables/About/Languages.php");
|
|
|
|
class DELETE_AboutLanguages extends Database {
|
|
protected readonly Ruleset $ruleset;
|
|
|
|
public function __construct() {
|
|
$this->ruleset = new Ruleset(strict: true);
|
|
$this->ruleset->validate_or_exit();
|
|
|
|
parent::__construct();
|
|
}
|
|
|
|
private function languages(): array {
|
|
$resp = (new Call(Endpoints::ABOUT_LANGUAGES->value))->get();
|
|
|
|
return array_column($resp->output(), LanguagesTable::ID->value);
|
|
}
|
|
|
|
// Delete languages cache file if it exists
|
|
public function main(): Response {
|
|
$this->db->for(LanguagesTable::NAME);
|
|
|
|
foreach ($this->languages() as $language){
|
|
$this->db->delete([LanguagesTable::ID->value => $language]);
|
|
}
|
|
|
|
return new Response();
|
|
}
|
|
} |