refactor: include Vegvisir source files from Reflect with a function

This commit is contained in:
Victor Westerlund 2025-10-30 18:43:42 +01:00
parent dbdde9fcaf
commit 3d809456d7
Signed by: vlw
GPG key ID: D0AD730E1057DFC6

View file

@ -5,25 +5,17 @@
use VV; use VV;
use Reflect\Path; use Reflect\Path;
class Scaffold { /**
/** * Include a source file from either Vegvisir or Reflect
* Include a source file *
* * @param string $pathname Relative path from project root to a source file
* @param string $pathname Relative path from project root to a source file */
*/ function load(string $pathname): void {
public static function include(string $pathname): void { // Load the Vegvisir VV clas from Reflect
if (!class_exists("VV")) { if (!class_exists("VV")) {
self::load_vegvisir_kernel();
}
require_once VV::root($pathname);
}
/**
* Load the Vegvisir VV class from Reflect
*/
private static function load_vegvisir_kernel(): void {
require_once Path::root("vegvisir/src/kernel/Init.php"); require_once Path::root("vegvisir/src/kernel/Init.php");
require_once Path::root("vegvisir/src/request/VV.php"); require_once Path::root("vegvisir/src/request/VV.php");
} }
}
require_once VV::root($pathname);
}