Christopher Vagnetoft
30dfd4889b
* Added request logging to com.noccy.apiclient * Added plugin com.noccy.watcher * Added pipe command and filter support * Fixes and stubs
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Spark\SparkApplication;
|
|
use Spark\Environment\Environment;
|
|
|
|
abstract class SparkPlug
|
|
{
|
|
abstract public function load();
|
|
|
|
public function getPlugin(string $name)
|
|
{
|
|
return SparkApplication::$instance->getPluginManager()->getPlugin($name);
|
|
}
|
|
|
|
public function getResource(string $name)
|
|
{
|
|
return SparkApplication::$instance->getResourceManager()->getNamedResource($name);
|
|
}
|
|
|
|
public function getEnvironment(): Environment
|
|
{
|
|
return SparkApplication::$instance->getEnvironment();
|
|
}
|
|
|
|
public function getApplication(): SparkApplication
|
|
{
|
|
return SparkApplication::$instance;
|
|
}
|
|
|
|
public function readConfig($file=null)
|
|
{
|
|
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();
|
|
}
|
|
|
|
public function getConfigDirectory()
|
|
{
|
|
return SparkApplication::$instance->getEnvironment()->getConfigDirectory();
|
|
}
|
|
|
|
} |