Installer tweaks

This commit is contained in:
2021-12-30 00:53:08 +01:00
parent 538383c33d
commit 5a1268aed6
5 changed files with 45 additions and 14 deletions

View File

@ -7,12 +7,14 @@ use Spark\Pipe\Filters\PhpFilter;
use Spark\Resource\ResourceType;
use Spark\SparkApplication;
$HELPERS = [];
function object(...$data) {
return (object)$data;
}
// ------- Helpers -------
$HELPERS = [];
function register_helper(string $name, callable $helper) {
global $HELPERS;
$HELPERS[$name] = $helper;
@ -28,6 +30,8 @@ function helper(string $name, ...$args) {
return $helper(...$args);
}
// ------ Plugins ------
function register_plugin(string $name, SparkPlug $plugin) {
$refl = new ReflectionClass($plugin);
$psr4 = object(
@ -50,6 +54,8 @@ function get_plugin(string $name) {
return SparkApplication::$instance->getPluginManager()->getPlugin($name);
}
// ------ Commands ------
function register_command(Command $command) {
SparkApplication::$instance->add($command);
}
@ -58,6 +64,8 @@ function get_environment(): Environment {
return SparkApplication::$instance->getEnvironment();
}
// ------ Resources ------
function register_resource_type(string $name, string $type) {
SparkApplication::$instance->getResourceManager()->registerResourceType($name, $type);
}