mirror of
https://codeberg.org/vlw/scaffold.git
synced 2025-11-05 06:02:42 +01:00
refactor: include Vegvisir source files from Reflect as a function (#3)
I know we just merged #2 and released verison 1.1.0 where the Vegvisir/Reflect crosstalk was supposed to be a class. But after using this briefly, I feel like it gets too verbose. This function will be called _a lot_ and therefore I think it should be pretty quick to type - just like the Vegvisir `VV` class. Instead of typing ```php use vlw\Scaffold\Scaffold; Scaffold::include("some/file.php"); ``` we can instead type ```php use function vlw\Scaffold\load; load("some/file.php"); ``` Reviewed-on: https://codeberg.org/vlw/scaffold/pulls/3
This commit is contained in:
parent
dbdde9fcaf
commit
e1d3a09966
1 changed files with 11 additions and 19 deletions
|
|
@ -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);
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue