Skip to content

Commit

Permalink
Validate site root (#3)
Browse files Browse the repository at this point in the history
* Initial commit.

* Validate site root.
  • Loading branch information
jmolivas authored Jun 30, 2016
1 parent 00b9d3a commit 3478b9d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
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;
}
}

0 comments on commit 3478b9d

Please sign in to comment.