Skip to content

Commit

Permalink
Use ZF2 prompt; renamed variable to avoid confusion.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Oct 15, 2014
1 parent 5bb34f1 commit 71d7733
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@

// Are we allowing user interaction?
$interactive = !$opts->getOption('non-interactive');
$getInput = array();
$userInputNeeded = array();

// Load user settings if we are not forcing defaults:
if (!$opts->getOption('use-defaults')) {
if ($opts->getOption('overridedir')) {
$overrideDir = $opts->getOption('overridedir');
} else if ($interactive) {
$getInput['overrideDir'] = true;
$userInputNeeded['overrideDir'] = true;
}
if ($opts->getOption('module-name')) {
if ($opts->getOption('module-name') !== 'disabled') {
Expand All @@ -87,7 +87,7 @@
}
}
} else if ($interactive) {
$getInput['module'] = true;
$userInputNeeded['module'] = true;
}

if ($opts->getOption('basepath')) {
Expand All @@ -96,7 +96,7 @@
die($result . "\n");
}
} else if ($interactive) {
$getInput['basePath'] = true;
$userInputNeeded['basePath'] = true;
}

// We assume "single site" mode unless the --multisite switch is set:
Expand All @@ -108,22 +108,22 @@
} else if (($bad = $opts->getOption('multisite')) && $bad !== true) {
die('Unexpected multisite mode: ' . $bad . "\n");
} else if ($interactive) {
$getInput['multisiteMode'] = true;
$userInputNeeded['multisiteMode'] = true;
}
}

// Now that we've validated as many parameters as possible, retrieve
// user input where needed.
if (isset($getInput['overrideDir'])) {
if (isset($userInputNeeded['overrideDir'])) {
$overrideDir = getOverrideDir($overrideDir);
}
if (isset($getInput['module'])) {
if (isset($userInputNeeded['module'])) {
$module = getModule();
}
if (isset($getInput['basePath'])) {
if (isset($userInputNeeded['basePath'])) {
$basePath = getBasePath($basePath);
}
if (isset($getInput['multisiteMode'])) {
if (isset($userInputNeeded['multisiteMode'])) {
$multisiteMode = getMultisiteMode();
}

Expand Down Expand Up @@ -453,19 +453,7 @@ function getHost()
*/
function getInput($prompt)
{
// Standard function for most uses
if (function_exists('readline')) {
$in = readline($prompt);
return $in;
} else {
// Or use our own if it doesn't exist (windows)
print $prompt;
$fp = fopen("php://stdin", "r");
$in = fgets($fp, 4094); // Maximum windows buffer size
fclose($fp);
// Seems to keep the carriage return if you don't trim
return trim($in);
}
return \Zend\Console\Prompt\Line::prompt($prompt, true);
}

/**
Expand Down

0 comments on commit 71d7733

Please sign in to comment.