2021-12-07 16:26:34 +00:00
|
|
|
<?php
|
|
|
|
|
2021-12-08 01:36:46 +00:00
|
|
|
use Spark\SparkApplication;
|
|
|
|
|
2021-12-07 16:26:34 +00:00
|
|
|
abstract class SparkPlug
|
|
|
|
{
|
|
|
|
abstract public function load();
|
2021-12-08 01:36:46 +00:00
|
|
|
|
|
|
|
public function getPlugin(string $name)
|
|
|
|
{
|
|
|
|
return SparkApplication::$instance->getPluginManager()->getPlugin($name);
|
|
|
|
}
|
|
|
|
|
2021-12-08 03:05:55 +00:00
|
|
|
function getResource(string $name)
|
|
|
|
{
|
2021-12-08 01:36:46 +00:00
|
|
|
return SparkApplication::$instance->getResourceManager()->getNamedResource($name);
|
|
|
|
}
|
|
|
|
|
2021-12-08 03:05:55 +00:00
|
|
|
function readConfig($file=null)
|
|
|
|
{
|
2021-12-08 01:36:46 +00:00
|
|
|
if (!$file) return;
|
|
|
|
$abs = get_environment()->getConfigDirectory() . "/" . $file;
|
|
|
|
if (!file_exists($abs)) {
|
|
|
|
//fprintf(STDERR, "warning: Can't read config file %s\n", $abs);
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return (array)json_decode(file_get_contents($abs), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getProjectDirectory()
|
|
|
|
{
|
|
|
|
return SparkApplication::$instance->getEnvironment()->getProjectDirectory();
|
|
|
|
}
|
2021-12-08 03:05:55 +00:00
|
|
|
|
2021-12-08 01:36:46 +00:00
|
|
|
|
2021-12-07 16:26:34 +00:00
|
|
|
}
|