flarum info: Display warning when in debug mode

Refs #1421.
This commit is contained in:
Franz Liedke 2018-09-01 16:57:44 +02:00
parent 5f5af894ab
commit 5374f8a352
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4
2 changed files with 27 additions and 4 deletions

View File

@ -13,6 +13,7 @@ namespace Flarum\Console;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
abstract class AbstractCommand extends Command
@ -55,12 +56,28 @@ abstract class AbstractCommand extends Command
}
/**
* Send an info string to the user.
* Send an info message to the user.
*
* @param string $string
* @param string $message
*/
protected function info($string)
protected function info($message)
{
$this->output->writeln("<info>$string</info>");
$this->output->writeln("<info>$message</info>");
}
/**
* Send an error or warning message to the user.
*
* If possible, this will send the message via STDERR.
*
* @param string $message
*/
protected function error($message)
{
if ($this->output instanceof ConsoleOutputInterface) {
$this->output->getErrorOutput()->writeln("<error>$message</error>");
} else {
$this->output->writeln("<error>$message</error>");
}
}
}

View File

@ -73,6 +73,12 @@ class InfoCommand extends AbstractCommand
$this->info('Base URL: '.$this->config['url']);
$this->info('Installation path: '.getcwd());
$this->info('Debug mode '.($this->config['debug'] ? 'ON' : 'off'));
if ($this->config['debug']) {
$this->error(
"Don't forget to turn off debug mode! It should never be turned on in a production system."
);
}
}
/**