Skip to content

Commit

Permalink
feat: spark routes shows "Required Filters"
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Nov 20, 2023
1 parent c168b16 commit baa9777
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions system/Commands/Utilities/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,30 @@ public function run(array $params)
}

CLI::table($tbody, $thead);

$this->showRequiredFilters();
}

private function showRequiredFilters(): void
{
$filterCollector = new FilterCollector();

$required = $filterCollector->getRequiredFilters();

$filters = [];

foreach ($required['before'] as $filter) {
$filters[] = CLI::color($filter, 'yellow');
}

CLI::write('Required Before Filters: ' . implode(', ', $filters));

$filters = [];

foreach ($required['after'] as $filter) {
$filters[] = CLI::color($filter, 'yellow');
}

CLI::write(' Required After Filters: ' . implode(', ', $filters));
}
}
9 changes: 9 additions & 0 deletions tests/system/Commands/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public function testRoutesCommand(): void
+---------+---------+---------------+----------------------------------------+----------------+---------------+
EOL;
$this->assertStringContainsString($expected, $this->getBuffer());

$expected = <<<'EOL'
Required Before Filters: forcehttps, pagecache
Required After Filters: pagecache, performance, toolbar
EOL;
$this->assertStringContainsString(
$expected,
preg_replace('/\033\[.+?m/u', '', $this->getBuffer())
);
}

public function testRoutesCommandSortByHandler(): void
Expand Down

0 comments on commit baa9777

Please sign in to comment.