Skip to content

Commit 6de421f

Browse files
authored
Merge pull request #852 from LordSimal/mark-duplicate-routes
highlight duplicate routes in routes panel
2 parents 2635f89 + f5a3ff7 commit 6de421f

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

templates/element/routes_panel.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010

1111
$routes = Cake\Routing\Router::routes();
1212

13-
$amountOfRoutesPerGroup = [];
13+
$amountOfRoutesPerGroup = $duplicateRoutes = [];
1414
foreach ($routes as $route) {
15+
// Count the amount
1516
$group = $route->defaults['plugin'] ?? 'app';
1617
if (!array_key_exists($group, $amountOfRoutesPerGroup)) {
1718
$amountOfRoutesPerGroup[$group] = 0;
1819
}
1920
$amountOfRoutesPerGroup[$group]++;
21+
22+
if (!array_key_exists($route->template, $duplicateRoutes)) {
23+
$duplicateRoutes[$route->template] = 0;
24+
}
25+
$duplicateRoutes[$route->template]++;
2026
}
2127

2228
$pluginNames = [];
@@ -70,6 +76,11 @@
7076
$class .= ' highlighted';
7177
}
7278

79+
// Mark duplicate routes
80+
if ($duplicateRoutes[$route->template] > 1) {
81+
$class .= ' duplicate-route';
82+
}
83+
7384
?>
7485
<tr class="<?= $class ?>">
7586
<td><?= h(Hash::get($route->options, '_name', $route->getName())) ?></td>

webroot/css/toolbar.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ pre,
270270
.debug-table td.left {
271271
text-align: left;
272272
}
273+
.debug-table .duplicate-route td {
274+
background: #ffea96;
275+
}
273276
.debug-table .highlighted td {
274277
background: #e7e9fd;
275278
}
@@ -625,3 +628,24 @@ pre,
625628
flex-wrap: wrap;
626629
margin: 0 -5px;
627630
}
631+
632+
.color-info-type {
633+
align-items: center;
634+
display: flex;
635+
}
636+
637+
.color-info-type:before {
638+
content: '';
639+
display: inline-block;
640+
height: 20px;
641+
margin-right: 10px;
642+
width: 20px;
643+
}
644+
645+
.color-info-type--current-route:before {
646+
background: #e7e9fd;
647+
}
648+
649+
.color-info-type--duplicate-route:before {
650+
background: #ffea96;
651+
}

0 commit comments

Comments
 (0)