Skip to content

Commit

Permalink
Refactoring init command & update license years
Browse files Browse the repository at this point in the history
  • Loading branch information
niksamokhvalov committed Dec 15, 2017
1 parent 71a0447 commit e3a302d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2016 [Notamedia Ltd.](http://nota.media)
Copyright © 2016-2017 [Notamedia Ltd.](http://nota.media)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
30 changes: 16 additions & 14 deletions src/Environment/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
*/
class InitCommand extends Command
{
/**
* @var string Code of the environment
*/
protected $environmentCode;
/**
* @var string Path to the environment directory.
*/
Expand All @@ -51,6 +47,10 @@ class InitCommand extends Command
* @var array Files that do not need to copy to the application when initializing the environment settings.
*/
protected $excludedFiles = ['config.php'];
/**
* @var string Type of the initialized environment.
*/
private $type;

/**
* {@inheritdoc}
Expand Down Expand Up @@ -92,27 +92,27 @@ protected function initialize(InputInterface $input, OutputInterface $output)
}

if ($input->getArgument('type')) {
$code = $input->getArgument('type');
$type = $input->getArgument('type');

if (!isset($environments[$code])) {
if (!isset($environments[$type])) {
throw new \Exception('Invalid environment code!');
}
} else {
foreach ($environments as $code => $environment) {
$choices[$code] = $environment['name'];
foreach ($environments as $type => $environment) {
$choices[$type] = $environment['name'];
}

$questionHelper = $this->getHelper('question');
$question = new ChoiceQuestion('<info>Which environment install?</info>', $choices, false);
$code = $questionHelper->ask($input, $output, $question);
$type = $questionHelper->ask($input, $output, $question);
}

if (!isset($environments[$code]['path'])) {
if (!isset($environments[$type]['path'])) {
throw new \Exception('Environment path not found!');
}

$this->environmentCode = $code;
$this->dir = $dir . '/' . $environments[$code]['path'];
$this->type = $type;
$this->dir = $dir . '/' . $environments[$type]['path'];
$this->config = include $this->dir . '/config.php';
}

Expand Down Expand Up @@ -361,10 +361,12 @@ protected function configureOptions(InputInterface $input, OutputInterface $outp
}

/**
* Gets type of initialized environment.
*
* @return string
*/
public function getEnvironmentCode()
public function getType()
{
return $this->environmentCode;
return $this->type;
}
}

0 comments on commit e3a302d

Please sign in to comment.