Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3751091
D169.id403.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D169.id403.diff
View Options
diff --git a/app/Console/Commands/ConfigShow.php b/app/Console/Commands/ConfigShow.php
new file mode 100644
--- /dev/null
+++ b/app/Console/Commands/ConfigShow.php
@@ -0,0 +1,138 @@
+<?php
+
+namespace Nasqueron\Notifications\Console\Commands;
+
+use Illuminate\Console\Command;
+
+use Nasqueron\Notifications\Phabricator\ProjectsMap;
+use Nasqueron\Notifications\Features;
+use Nasqueron\Notifications\Services;
+
+use Config;
+
+class ConfigShow extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'config:show';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Show notifications center configuration';
+
+ /**
+ * Creates a new command instance.
+ *
+ * @return void
+ */
+ public function __construct () {
+ parent::__construct();
+ }
+
+ ///
+ /// Prepare information tables
+ ///
+
+ /**
+ * Gets the services (defined in credentials.json) as table rows
+ *
+ * @return arrray
+ */
+ protected function getServicesTableRows () {
+ $rows = [];
+ foreach (Services::Get() as $service) {
+ if (isset($service->instance)) {
+ $instance = $service->instance;
+ } else {
+ $instance = 'ø';
+ }
+ $rows[] = [
+ $service->gate,
+ $service->door,
+ $instance,
+ $this->getServiveStatus($service)
+ ];
+ }
+ return $rows;
+ }
+
+ /**
+ * Gets service status
+ *
+ * @param $service The service to check
+ * @return string A description of the issue if something is wrong; otherwise, "✓".
+ */
+ protected function getServiveStatus ($service) {
+ if ($service->gate === 'Phabricator') {
+ // Ensure the projects map is cached
+ $map = ProjectsMap::fetch($service->instance);
+ if (!$map->isCached()) {
+ return "Projects map not cached.";
+ }
+ }
+ return "✓";
+ }
+
+ /**
+ * Gets features as table rows
+ *
+ * @return array
+ */
+ protected function getFeaturesTableRows () {
+ $rows = [];
+ foreach (Features::getAll() as $key => $value) {
+ if ($value) {
+ $checkMark = '✓';
+ } else {
+ $checkMark = '';
+ }
+
+ $rows[] = [$key, $checkMark];
+ }
+ return $rows;
+ }
+
+ ///
+ /// Handle the command
+ ///
+
+ /**
+ * Executes the console command.
+ *
+ * @return mixed
+ */
+ public function handle () {
+ $this->printGates();
+ $this->printFeatures();
+ $this->printServices();
+ }
+
+ protected final function printGates () {
+ $this->info("Gates:\n");
+ foreach (Config::get('gate.controllers') as $gate) {
+ $this->line('- ' . $gate);
+ }
+ }
+
+ protected final function printFeatures () {
+ $this->info("\nFeatures:\n");
+ $this->table(
+ ['Feature', 'Enabled'],
+ $this->getFeaturesTableRows()
+ );
+ }
+
+ protected final function printServices () {
+ $this->info("\nServices declared in credentials:\n");
+ $this->table(
+ ['Gate', 'Door', 'Instance', 'Status'],
+ $this->getServicesTableRows()
+ );
+ }
+}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -13,6 +13,7 @@
* @var array
*/
protected $commands = [
+ \Nasqueron\Notifications\Console\Commands\ConfigShow::class,
\Nasqueron\Notifications\Console\Commands\Inspire::class,
\Nasqueron\Notifications\Console\Commands\PhabricatorGetProjectsMap::class,
];
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 18, 05:54 (21 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2250190
Default Alt Text
D169.id403.diff (3 KB)
Attached To
Mode
D169: New artisan command: config:show
Attached
Detach File
Event Timeline
Log In to Comment