Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion system/Router/DefinedRouteCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function collect(): Generator
if (is_string($handler) || $handler instanceof Closure) {

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

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

$routeName = $this->routeCollection->getRoutesOptions($route)['as'] ?? $route;
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 @@ -1649,7 +1652,7 @@ public function resetRoutes()
* array{
* filter?: string|list<string>, namespace?: string, hostname?: string,
* subdomain?: string, offset?: int, priority?: int, as?: string,
* redirect?: string
* redirect?: int
* }
* >
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Router/DefinedRouteCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testCollect()
'method' => 'get',
'route' => 'about',
'name' => 'about',
'handler' => '(Closure)',
'handler' => '(View) pages/about',
],
];
$this->assertSame($expected, $definedRoutes);
Expand Down
14 changes: 12 additions & 2 deletions user_guide_src/source/changelogs/v4.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,17 @@ Enhancements
Commands
========

- Now ``spark routes`` command can specify the host in the request URL.
See :ref:`routing-spark-routes-specify-host`.
- **spark routes:**
- Now you can specify the host in the request URL.
See :ref:`routing-spark-routes-specify-host`.
- It shows view files of :ref:`view-routes` in *Handler* like the following:

+---------+-------------+------+------------------------------+----------------+---------------+
| Method | Route | Name | Handler | Before Filters | After Filters |
+---------+-------------+------+------------------------------+----------------+---------------+
| GET | about | » | (View) pages/about | | toolbar |
+---------+-------------+------+------------------------------+----------------+---------------+


Testing
=======
Expand Down Expand Up @@ -151,6 +160,7 @@ Others
- **Error Handling:** Now you can use :ref:`custom-exception-handlers`.
- **RedirectException:** can also take an object that implements ResponseInterface as its first argument.
- **RedirectException:** implements ResponsableInterface.
- **DebugBar:** Now :ref:`view-routes` are displayed in *DEFINED ROUTES* on the *Routes* tab.

Message Changes
***************
Expand Down