From fcb3a7261105b80078c4d644913ee1f0e7f55f2d Mon Sep 17 00:00:00 2001 From: Daniel Klabbers Date: Fri, 30 Jul 2021 10:58:32 +0200 Subject: [PATCH] added mysql version, queue and mail driver --- .../src/Foundation/Console/InfoCommand.php | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/framework/core/src/Foundation/Console/InfoCommand.php b/framework/core/src/Foundation/Console/InfoCommand.php index a0f8d4773..c61e179f3 100644 --- a/framework/core/src/Foundation/Console/InfoCommand.php +++ b/framework/core/src/Foundation/Console/InfoCommand.php @@ -13,6 +13,11 @@ use Flarum\Console\AbstractCommand; use Flarum\Extension\ExtensionManager; use Flarum\Foundation\Application; use Flarum\Foundation\Config; +use Flarum\Settings\SettingsRepositoryInterface; +use Illuminate\Contracts\Queue\Queue; +use Illuminate\Database\ConnectionInterface; +use Illuminate\Database\MySqlConnection; +use Illuminate\Support\Str; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Helper\TableStyle; @@ -29,13 +34,15 @@ class InfoCommand extends AbstractCommand protected $config; /** - * @param ExtensionManager $extensions - * @param Config config + * @var SettingsRepositoryInterface */ - public function __construct(ExtensionManager $extensions, Config $config) + protected $settings; + + public function __construct(ExtensionManager $extensions, Config $config, SettingsRepositoryInterface $settings) { $this->extensions = $extensions; $this->config = $config; + $this->settings = $settings; parent::__construct(); } @@ -59,6 +66,7 @@ class InfoCommand extends AbstractCommand $this->output->writeln("Flarum core $coreVersion"); $this->output->writeln('PHP version: '.PHP_VERSION); + $this->output->writeln('MySQL version: '.$this->identifyDatabaseVersion()); $phpExtensions = implode(', ', get_loaded_extensions()); $this->output->writeln("Loaded extensions: $phpExtensions"); @@ -67,9 +75,12 @@ class InfoCommand extends AbstractCommand $this->output->writeln('Base URL: '.$this->config->url()); $this->output->writeln('Installation path: '.getcwd()); - $this->output->writeln('Debug mode: '.($this->config->inDebugMode() ? 'ON' : 'off')); + $this->output->writeln('Queue driver: '.$this->identifyQueueDriver()); + $this->output->writeln('Mail driver: '.$this->settings->get('mail_driver', 'unknown')); + $this->output->writeln('Debug mode: '.($this->config->inDebugMode() ? 'ON' : 'off')); if ($this->config->inDebugMode()) { + $this->output->writeln(''); $this->error( "Don't forget to turn off debug mode! It should never be turned on in a production system." ); @@ -126,4 +137,27 @@ class InfoCommand extends AbstractCommand return $fallback; } + + private function identifyQueueDriver(): string + { + // Get instantiated queue class + $queue = resolve(Queue::class); + // Get class name + $queue = get_class($queue); + // Drop the namespace + $queue = Str::afterLast($queue, '\\'); + // Lowercase the class name + $queue = strtolower($queue); + // Drop everything like queue SyncQueue, RedisQueue + $queue = str_replace('queue', null, $queue); + + return $queue; + } + + private function identifyDatabaseVersion(): string + { + /** @var MySqlConnection $connection */ + $connection = resolve(ConnectionInterface::class); + return $connection->getPdo()->getAttribute(\PDO::ATTR_SERVER_VERSION); + } }