Page MenuHomeDevCentral

D790.id1998.diff
No OneTemporary

D790.id1998.diff

diff --git a/app/Config/Reporting/FeatureReportEntry.php b/app/Config/Reporting/FeatureReportEntry.php
--- a/app/Config/Reporting/FeatureReportEntry.php
+++ b/app/Config/Reporting/FeatureReportEntry.php
@@ -33,4 +33,32 @@
$this->enabled = $enabled;
}
+ ///
+ /// Format
+ ///
+
+ /**
+ * Gets the entry as an array.
+ *
+ * @return string[]
+ */
+ public function toArray () : array {
+ return [
+ $this->name,
+ (string)$this->enabled,
+ ];
+ }
+
+ /**
+ * Gets the entry as an array. Formats empty string.
+ *
+ * @return string[]
+ */
+ public function toFancyArray () : array {
+ return [
+ $this->name,
+ ($this->enabled) ? '✓' : ''
+ ];
+ }
+
}
diff --git a/app/Config/Reporting/ServiceReportEntry.php b/app/Config/Reporting/ServiceReportEntry.php
--- a/app/Config/Reporting/ServiceReportEntry.php
+++ b/app/Config/Reporting/ServiceReportEntry.php
@@ -99,4 +99,36 @@
return !$map->isCached();
}
+ ///
+ /// Format
+ ///
+
+ /**
+ * Gets the entry as an array. Formats empty string.
+ *
+ * @return string[]
+ */
+ public function toArray () : array {
+ return [
+ $this->gate,
+ $this->door,
+ $this->instance,
+ $this->status,
+ ];
+ }
+
+ /**
+ * Gets the entry as an array. Formats empty string.
+ *
+ * @return string[]
+ */
+ public function toFancyArray () : array {
+ return [
+ $this->gate,
+ $this->door,
+ ($this->instance === '') ? 'ø' : $this->instance,
+ ($this->status === '') ? '✓' : $this->status,
+ ];
+ }
+
}
diff --git a/app/Console/Commands/ConfigShow.php b/app/Console/Commands/ConfigShow.php
--- a/app/Console/Commands/ConfigShow.php
+++ b/app/Console/Commands/ConfigShow.php
@@ -4,12 +4,8 @@
use Illuminate\Console\Command;
-use Nasqueron\Notifications\Config\Features;
-use Nasqueron\Notifications\Config\Services\Service;
-
-use Config;
-use ProjectsMap;
-use Services;
+use Nasqueron\Notifications\Config\Reporting\ConfigReport;
+use Nasqueron\Notifications\Config\Reporting\ServiceReportEntry;
class ConfigShow extends Command
{
@@ -28,10 +24,17 @@
protected $description = 'Show notifications center configuration';
/**
+ * @var \Nasqueron\Notifications\Config\Reporting\ConfigReport
+ */
+ private $report;
+
+ /**
* Creates a new command instance.
*/
public function __construct () {
parent::__construct();
+
+ $this->report = new ConfigReport();
}
///
@@ -41,37 +44,16 @@
/**
* Gets the services (defined in credentials.json) as table rows.
*
- * @return \Nasqueron\Notifications\Config\Services\Service[]
+ * @return array
*/
protected function getServicesTableRows () : array {
$rows = [];
- foreach (Services::get() as $service) {
- $rows[] = [
- $service->gate,
- $service->door,
- $service->getInstanceName(),
- $this->getServiveStatus($service)
- ];
- }
- return $rows;
- }
- /**
- * Gets service status.
- *
- * @param \Nasqueron\Notifications\Config\Services\Service $service The service to check
- * @return string A description of the issue if something is wrong; otherwise, "✓".
- */
- protected function getServiveStatus (Service $service) : string {
- if ($service->gate === 'Phabricator') {
- // Ensure the projects map is cached
- $map = \ProjectsMap::fetch($service->door);
- if (!$map->isCached()) {
- return "Projects map not cached.";
- }
+ foreach ($this->report->services as $service) {
+ $rows[] = $service->toFancyArray();
}
- return "✓";
+ return $rows;
}
/**
@@ -81,15 +63,11 @@
*/
protected function getFeaturesTableRows () : array {
$rows = [];
- foreach (Features::getAll() as $key => $value) {
- if ($value) {
- $checkMark = '✓';
- } else {
- $checkMark = '';
- }
-
- $rows[] = [$key, $checkMark];
+
+ foreach ($this->report->features as $feature) {
+ $rows[] = $feature->toFancyArray();
}
+
return $rows;
}
@@ -108,7 +86,7 @@
protected final function printGates () : void {
$this->info("Gates:\n");
- foreach (Config::get('gate.controllers') as $gate) {
+ foreach ($this->report->gates as $gate) {
$this->line('- ' . $gate);
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 05:46 (17 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2307569
Default Alt Text
D790.id1998.diff (4 KB)

Event Timeline