remove usage of getenv from codebase (#1861)

This commit is contained in:
Kevin Papst
2020-08-02 01:02:04 +02:00
committed by GitHub
parent 6f8c0e3cb6
commit 476e6ca150
14 changed files with 122 additions and 123 deletions

View File

@@ -28,14 +28,16 @@ class CreateReleaseCommand extends Command
/**
* @var string
*/
protected $rootDir = '';
private $rootDir = '';
/**
* @param string $projectDirectory
* @var string
*/
public function __construct(string $projectDirectory)
private $environment;
public function __construct(string $projectDirectory, string $kernelEnvironment)
{
$this->rootDir = realpath($projectDirectory);
$this->environment = $kernelEnvironment;
parent::__construct();
}
@@ -51,14 +53,16 @@ class CreateReleaseCommand extends Command
->addOption('directory', null, InputOption::VALUE_OPTIONAL, 'Directory where the release package will be stored', '/tmp/')
->addOption('release', null, InputOption::VALUE_OPTIONAL, 'The version that should be zipped', Constants::VERSION)
;
}
/*
* Hide this command in production.
* Maybe it should be de-activated completely?!
*/
if (getenv('APP_ENV') === 'prod') {
$this->setHidden(true);
}
/**
* Make sure that this command CANNOT be executed in production.
*
* @return bool
*/
public function isEnabled()
{
return $this->environment !== 'prod';
}
/**
@@ -70,12 +74,6 @@ class CreateReleaseCommand extends Command
{
$io = new SymfonyStyle($input, $output);
if (getenv('APP_ENV') === 'prod') {
$io->error('kimai:create-release is not allowed in production');
return -2;
}
$directory = $input->getOption('directory');
if ($directory[0] === '/') {

View File

@@ -29,6 +29,17 @@ use Symfony\Component\Console\Style\SymfonyStyle;
*/
class ResetCommand extends Command
{
/**
* @var string
*/
private $environment;
public function __construct(string $kernelEnvironment)
{
$this->environment = $kernelEnvironment;
parent::__construct();
}
/**
* {@inheritdoc}
*/
@@ -55,7 +66,7 @@ EOT
*/
public function isEnabled()
{
return getenv('APP_ENV') !== 'prod';
return $this->environment !== 'prod';
}
/**