Skip to content

Commit

Permalink
RoutingPanel: displays one-way flags [Closes #274]
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 5, 2021
1 parent 68f41ad commit 30aadfb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"php": ">=7.2",
"nette/component-model": "^3.0",
"nette/http": "^3.0.2",
"nette/routing": "~3.0.0",
"nette/routing": "~3.0.2",
"nette/utils": "^3.2.1"
},
"suggest": {
Expand Down
10 changes: 6 additions & 4 deletions src/Bridges/ApplicationTracy/RoutingPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ private function analyse(
Routing\Router $router,
string $module = '',
bool $parentMatches = true,
int $level = -1
int $level = -1,
int $flag = 0
): void {
if ($router instanceof Routing\RouteList) {
try {
Expand All @@ -98,8 +99,9 @@ private function analyse(
}
$next = count($this->routers);
$parentModule = $module . ($router instanceof Nette\Application\Routers\RouteList ? $router->getModule() : '');
foreach ($router->getRouters() as $subRouter) {
$this->analyse($subRouter, $parentModule, $parentMatches, $level + 1);
$flags = $router->getFlags();
foreach ($router->getRouters() as $i => $subRouter) {
$this->analyse($subRouter, $parentModule, $parentMatches, $level + 1, $flags[$i]);
}

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

$matched = 'no';
$matched = $flag & Routing\RouteList::ONE_WAY ? 'oneway' : 'no';
$params = $e = null;
try {
$params = $parentMatches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ use Tracy\Helpers;
<tbody>
<?php foreach ($routers as $router): ?>
<tr class="<?= $router->matched ?>" style="border-width: <?=($router->gutterTop ?? 0) * 3?>px 0 <?=($router->gutterBottom ?? 0) * 3?>px <?=$router->level * 6?>px">
<td class="symbol"><?= ['yes' => '', 'may' => '', 'no' => '', 'error' => ''][$router->matched] ?></td>
<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]) ?>"
><?= ['yes' => '', 'may' => '', 'no' => '', 'oneway' => '', 'error' => ''][$router->matched] ?></td>

<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>

Expand Down

0 comments on commit 30aadfb

Please sign in to comment.