Initial commit
This commit is contained in:
38
src/Commands/Command.php
Normal file
38
src/Commands/Command.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Spark\Commands;
|
||||
|
||||
use Flare\SparkApplication;
|
||||
use Spark\Environment\Environment;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command as CommandCommand;
|
||||
|
||||
abstract class Command extends CommandCommand
|
||||
{
|
||||
public function getEnvironment(): Environment
|
||||
{
|
||||
/** @var SparkApplication */
|
||||
$app = $this->getApplication();
|
||||
if (!$app) return null;
|
||||
return $app->getEnvironment();
|
||||
}
|
||||
|
||||
public function loadEnvironment(string $path)
|
||||
{
|
||||
/** @var SparkApplication */
|
||||
$app = $this->getApplication();
|
||||
$app->loadEnvironment($path);
|
||||
}
|
||||
|
||||
public function createEnvironment(string|null $path=null)
|
||||
{
|
||||
if (empty($path)) {
|
||||
$path = getcwd();
|
||||
}
|
||||
/** @var SparkApplication */
|
||||
$app = $this->getApplication();
|
||||
$app->createEnvironment($path);
|
||||
$app->loadEnvironment($path);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user