Skip to content

Commit

Permalink
feat: improve spark routes output for View routes
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jul 3, 2023
1 parent e42f81a commit 30750e3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion system/Commands/Utilities/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ public function run(array $params)
$filters = $filterCollector->get($method, $sampleUri);

if ($handler instanceof Closure) {
$handler = '(Closure)';
$view = $collection->getRoutesOptions($route)['view'] ?? false;

$handler = $view ? '(View) ' . $view : '(Closure)';
}

$routeName = $collection->getRoutesOptions($route)['as'] ?? '»';
Expand Down
7 changes: 5 additions & 2 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,10 @@ public function view(string $from, string $view, ?array $options = null): RouteC
->setData(['segments' => $data], 'raw')
->render($view, $options);

$this->create('get', $from, $to, $options);
$routeOptions = $options ?? [];
$routeOptions = array_merge($routeOptions, ['view' => $view]);

$this->create('get', $from, $to, $routeOptions);

return $this;
}
Expand Down Expand Up @@ -1644,7 +1647,7 @@ public function resetRoutes()
* array{
* filter?: string|list<string>, namespace?: string, hostname?: string,
* subdomain?: string, offset?: int, priority?: int, as?: string,
* redirect?: int
* redirect?: int, view?: true
* }
* >
*/
Expand Down

0 comments on commit 30750e3

Please sign in to comment.