// of pages instead of a single page.
try { $params =
$route['route_params'
] ??
[];
$url = Url::
fromRoute($route['route_name'
],
$params);
// Skip this route if the current user cannot access it.
if (!
$url->
access()) { continue;
} // Generate the link HTML directly, using toString(), to catch
// missing parameter exceptions now instead of at render time.
$topics[$id] = Link::
fromTextAndUrl($title,
$url)->
toString();
// If the line above didn't generate an exception, we have a good
// link that the user can access.
$made_link = TRUE;
break;
} catch (\Exception
$e) { // Exceptions are normally due to routes that need parameters. If
// there is an exception, just try the next route and see if we can
// find one that will work for us.
} }