Initial commit
This commit is contained in:
73
src/SparkApplication.php
Normal file
73
src/SparkApplication.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Spark;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Spark\Environment\Environment;
|
||||
use Spark\Plugin\PluginManager;
|
||||
use Spark\Resource\ResourceManager;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Logger\ConsoleLogger;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class SparkApplication extends Application
|
||||
{
|
||||
public static SparkApplication $instance;
|
||||
|
||||
private Environment $environment;
|
||||
|
||||
private ResourceManager $resourceManager;
|
||||
|
||||
private PluginManager $pluginManager;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct("Spark", "dev");
|
||||
self::$instance = $this;
|
||||
|
||||
$this->resourceManager = new ResourceManager();
|
||||
$this->pluginManager = new PluginManager();
|
||||
|
||||
$this->environment = Environment::createFromDirectory();
|
||||
$this->environment->loadEnvironment();
|
||||
|
||||
$this->add(new Commands\RunCommand());
|
||||
$this->add(new Commands\ResourcesCommand());
|
||||
$this->add(new Commands\ReplCommand());
|
||||
|
||||
}
|
||||
|
||||
public function getPluginManager(): PluginManager
|
||||
{
|
||||
return $this->pluginManager;
|
||||
}
|
||||
|
||||
public function getEnvironment(): Environment
|
||||
{
|
||||
// if (empty($this->environment)) {
|
||||
// $this->environment = Environment::createFromDirectory();
|
||||
// $this->environment->setLogger($this->logger);
|
||||
// }
|
||||
return $this->environment;
|
||||
}
|
||||
|
||||
public function getResourceManager(): ResourceManager
|
||||
{
|
||||
return $this->resourceManager;
|
||||
}
|
||||
|
||||
public function getLogger(): LoggerInterface
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
public function doRun(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->logger = new ConsoleLogger($output);
|
||||
parent::doRun($input, $output);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user