Skip to content

Commit 7e8d965

Browse files
committed
feat: spark routes shows "Required Filters"
1 parent cf962fc commit 7e8d965

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

system/Commands/Utilities/Routes.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,30 @@ public function run(array $params)
192192
}
193193

194194
CLI::table($tbody, $thead);
195+
196+
$this->showRequiredFilters();
197+
}
198+
199+
private function showRequiredFilters(): void
200+
{
201+
$filterCollector = new FilterCollector();
202+
203+
$required = $filterCollector->getRequiredFilters();
204+
205+
$filters = [];
206+
207+
foreach ($required['before'] as $filter) {
208+
$filters[] = CLI::color($filter, 'yellow');
209+
}
210+
211+
CLI::write('Required Before Filters: ' . implode(', ', $filters));
212+
213+
$filters = [];
214+
215+
foreach ($required['after'] as $filter) {
216+
$filters[] = CLI::color($filter, 'yellow');
217+
}
218+
219+
CLI::write(' Required After Filters: ' . implode(', ', $filters));
195220
}
196221
}

tests/system/Commands/RoutesTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ public function testRoutesCommand(): void
7676
+---------+---------+---------------+----------------------------------------+----------------+---------------+
7777
EOL;
7878
$this->assertStringContainsString($expected, $this->getBuffer());
79+
80+
$expected = <<<'EOL'
81+
Required Before Filters: forcehttps, pagecache
82+
Required After Filters: pagecache, performance, toolbar
83+
EOL;
84+
$this->assertStringContainsString(
85+
$expected,
86+
preg_replace('/\033\[.+?m/u', '', $this->getBuffer())
87+
);
7988
}
8089

8190
public function testRoutesCommandSortByHandler(): void

0 commit comments

Comments
 (0)