feat: add dedicated class for crosstalk between Vegvisir and Reflect (#2)

In this PR we move the Vegvisir `VV` class import into Reflect from the API class into its own `Scaffold` class. This new class will include everything that is required for crosstalk between Vegvisir and Reflect.

Reviewed-on: https://codeberg.org/vlw/scaffold/pulls/2
This commit is contained in:
Victor Westerlund 2025-10-30 17:41:31 +01:00
parent 3357416ad0
commit dbdde9fcaf
2 changed files with 29 additions and 4 deletions

View file

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