38 lines
950 B
PHP
38 lines
950 B
PHP
|
<?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);
|
||
|
}
|
||
|
|
||
|
}
|