Skip to content

Commit c736251

Browse files
committed
RoutingPanel: displays one-way flags [Closes #274]
1 parent 6e3c171 commit c736251

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"php": ">=7.2",
1919
"nette/component-model": "^3.0",
2020
"nette/http": "^3.0.2",
21-
"nette/routing": "~3.0.0",
21+
"nette/routing": "~3.0.2",
2222
"nette/utils": "^3.2.1"
2323
},
2424
"suggest": {

src/Bridges/ApplicationTracy/RoutingPanel.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ private function analyse(
8989
Routing\Router $router,
9090
string $module = '',
9191
bool $parentMatches = true,
92-
int $level = -1
92+
int $level = -1,
93+
int $flag = 0
9394
): void {
9495
if ($router instanceof Routing\RouteList) {
9596
try {
@@ -98,8 +99,9 @@ private function analyse(
9899
}
99100
$next = count($this->routers);
100101
$parentModule = $module . ($router instanceof Nette\Application\Routers\RouteList ? $router->getModule() : '');
101-
foreach ($router->getRouters() as $subRouter) {
102-
$this->analyse($subRouter, $parentModule, $parentMatches, $level + 1);
102+
$flags = $router->getFlags();
103+
foreach ($router->getRouters() as $i => $subRouter) {
104+
$this->analyse($subRouter, $parentModule, $parentMatches, $level + 1, $flags[$i]);
103105
}
104106

105107
if ($info = $this->routers[$next] ?? null) {
@@ -111,7 +113,7 @@ private function analyse(
111113
return;
112114
}
113115

114-
$matched = 'no';
116+
$matched = $flag & Routing\RouteList::ONE_WAY ? 'oneway' : 'no';
115117
$params = $e = null;
116118
try {
117119
$params = $parentMatches

src/Bridges/ApplicationTracy/templates/RoutingPanel.panel.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ use Tracy\Helpers;
8181
<tbody>
8282
<?php foreach ($routers as $router): ?>
8383
<tr class="<?= $router->matched ?>" style="border-width: <?=($router->gutterTop ?? 0) * 3?>px 0 <?=($router->gutterBottom ?? 0) * 3?>px <?=$router->level * 6?>px">
84-
<td class="symbol"><?= ['yes' => '', 'may' => '', 'no' => '', 'error' => ''][$router->matched] ?></td>
84+
<td class="symbol" title="<?= Helpers::escapeHtml(['yes' => 'matched as first', 'may' => 'suitable but not matched as first', 'no' => '', 'oneway' => 'one-way', 'error' => 'error'][$router->matched]) ?>"
85+
><?= ['yes' => '', 'may' => '', 'no' => '', 'oneway' => '', 'error' => ''][$router->matched] ?></td>
8586

8687
<td><code title="<?= Helpers::escapeHtml($router->class) ?>"><?= isset($router->mask) ? str_replace(['/', '-'], ['<wbr>/', '<wbr>-'], Helpers::escapeHtml($router->mask)) : str_replace('\\', '<wbr>\\', Helpers::escapeHtml($router->class)) ?></code></td>
8788

0 commit comments

Comments
 (0)