Issue #3586573: Replace hardcoded /admin/ paths with route-based URL generation
Closes #3586573.
Replaces three hardcoded /admin/... path strings with route-based URL generation so Monitoring works correctly on sites using Rename Admin Paths (or any module that rewrites admin paths at the routing layer).
Changes
src/Controller/SensorList.php: the Edit dropdown link'sdestinationquery param was hardcoded to the literal stringadmin/reports/monitoring. Replaced withUrl::fromRoute('monitoring.sensor_list')->toString(). Added theDrupal\Core\Urlimport.src/Plugin/monitoring/SensorPlugin/WatchdogAggregatorSensorPlugin.php:Url::fromUserInput('/admin/reports/dblog/event/' . $wid)→Url::fromRoute('dblog.event', ['event_id' => $wid]). Thedblog.eventroute is guaranteed by this plugin'sprovider: 'dblog'attribute, so no guard is needed.src/Plugin/monitoring/SensorPlugin/ImageMissingStyleSensorPlugin.php:Url::fromUserInput('/admin/content/files/usage/' . $fid)→Url::fromRoute('view.files.page_2', ['arg_0' => $fid]). Wrapped in aRouteProvider::getRouteByName()/RouteNotFoundExceptionguard so the sensor degrades to a plain count (no link) if the shippedfilesview or its usage page display has been removed or renamed by the site builder.
Backwards compatibility
No functional change on sites without Rename Admin Paths — the generated URLs resolve to the same paths as before. No config or schema changes.
Manual test
With Rename Admin Paths installed and admin renamed to e.g. adm:
- Edit any sensor from the sensors overview, save — redirect now lands on
/adm/reports/monitoringinstead of/admin/reports/monitoring. - Configure a
watchdog_aggregatorsensor with verbose output; trigger any watchdog row; the linkedwidresolves to/adm/reports/dblog/event/{id}. - Configure the
image_style_missingsensor; the "N places" link resolves to/adm/content/files/usage/{fid}. Remove or rename thepage_2display on thefilesview and confirm the sensor still renders (as plain text) without throwing.
Note on view.files.page_2
That's the default display id of the core-shipped files view's usage page. Since admins can rename/delete the display, the code guards against the missing-route case. If a maintainer prefers a sturdier lookup, an alternative would be to iterate \Drupal::entityTypeManager()->getStorage('view')->load('files')'s displays and match by path — happy to revise if preferred.