Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate site root #3

Merged
merged 4 commits into from
Jun 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions bin/drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@
exit(0);
}

if ($isValidDrupal) {
$drupalConsoleLauncher = new DrupalConsoleLauncher();
$drupalConsoleLauncher->launch($argvInputReader->get('root'));
if (!$isValidDrupal) {
echo 'Invalid site root : ' . $argvInputReader->get('root') . PHP_EOL;

exit(0);
exit(1);
}

$drupalConsoleLauncher = new DrupalConsoleLauncher();
$launch = $drupalConsoleLauncher->launch($argvInputReader->get('root'));

if (!$launch) {
/* ask to install drupal console */
echo 'Drupal Console is not installed at '. PHP_EOL .
'Site root : ' . $argvInputReader->get('root') . PHP_EOL .
'Execute:' . PHP_EOL .
'composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader' . PHP_EOL;

exit(1);
}
6 changes: 3 additions & 3 deletions src/Utils/ArgvInputReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ public function getAll()
return $this->options;
}

public function setOptionsAsArgv() {
foreach($this->options as $optionName => $optionValue) {
public function setOptionsAsArgv()
{
foreach ($this->options as $optionName => $optionValue) {
if ($optionName == 'command') {
continue;
}
Expand All @@ -192,5 +193,4 @@ public function setOptionsAsArgv() {
}
}
}

}
6 changes: 4 additions & 2 deletions src/Utils/DrupalConsoleLauncher.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ public function launch($root)
}

if (!file_exists($drupal)) {
/* ask to install drupal console */
return false;
}

/* Add option to identify if pre-launched */
// $_SERVER['argv'][] = '--pre-launch';
// $_SERVER['argv'][] = '--pre-launch';

$drupal = realpath($drupal) . '.php';

include_once $drupal;

return true;
}
}