feat: add Vegvisir source loading from Reflect

This commit is contained in:
Victor Westerlund 2025-10-30 17:36:19 +01:00
parent 3357416ad0
commit b2017bc313
Signed by: vlw
GPG key ID: D0AD730E1057DFC6
2 changed files with 29 additions and 4 deletions

View file

@ -7,12 +7,8 @@
namespace vlw\Scaffold\API;
use Reflect\Path;
use Reflect\Rules\Ruleset;
require_once Path::root("vegvisir/src/kernel/Init.php");
require_once Path::root("vegvisir/src/request/VV.php");
class API {
/**
* Create a new API request with automatic request validation

29
src/Scaffold.php Normal file
View file

@ -0,0 +1,29 @@
<?php
namespace vlw\Scaffold;
use VV;
use Reflect\Path;
class Scaffold {
/**
* Include a source file
*
* @param string $pathname Relative path from project root to a source file
*/
public static function include(string $pathname): void {
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/request/VV.php");
}
}