From c009117834c2f249a6a444cb0a41a85cba5e3f15 Mon Sep 17 00:00:00 2001 From: kenjis Date: Mon, 3 Jul 2023 19:30:03 +0900 Subject: [PATCH 1/3] docs: fix @phpstan-return --- system/Router/RouteCollection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 21fa22dda707..5e4cdb36ef6e 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1649,7 +1649,7 @@ public function resetRoutes() * array{ * filter?: string|list, namespace?: string, hostname?: string, * subdomain?: string, offset?: int, priority?: int, as?: string, - * redirect?: string + * redirect?: int * } * > */ From 3f3d2162367f613401f4e5f64de50f2e0d79788c Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 4 Jul 2023 13:12:54 +0900 Subject: [PATCH 2/3] feat: improve `spark routes` output for View routes --- system/Router/DefinedRouteCollector.php | 4 +++- system/Router/RouteCollection.php | 5 ++++- tests/system/Router/DefinedRouteCollectorTest.php | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/system/Router/DefinedRouteCollector.php b/system/Router/DefinedRouteCollector.php index eeae28379d04..f77383fa6cef 100644 --- a/system/Router/DefinedRouteCollector.php +++ b/system/Router/DefinedRouteCollector.php @@ -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; diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 5e4cdb36ef6e..3e45d6b95588 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -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; } diff --git a/tests/system/Router/DefinedRouteCollectorTest.php b/tests/system/Router/DefinedRouteCollectorTest.php index 619f4386886f..ba74cec1a86a 100644 --- a/tests/system/Router/DefinedRouteCollectorTest.php +++ b/tests/system/Router/DefinedRouteCollectorTest.php @@ -82,7 +82,7 @@ public function testCollect() 'method' => 'get', 'route' => 'about', 'name' => 'about', - 'handler' => '(Closure)', + 'handler' => '(View) pages/about', ], ]; $this->assertSame($expected, $definedRoutes); From 0aa5dbd1dd5cfecdc64a7d06a24c5a1caadcfad8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 5 Jul 2023 08:09:59 +0900 Subject: [PATCH 3/3] docs: add changelog --- user_guide_src/source/changelogs/v4.4.0.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index 20db5a2d7b38..6b77eac7ecc9 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -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 ======= @@ -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 ***************