diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 094a339..d5f5a52 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1689,6 +1689,18 @@ function theme_links($variables) { $class[] = 'last'; } + $link_element = array( + '#type' => 'link', + '#title' => $link['title'], + '#options' => array_diff_key($link, drupal_map_assoc(array('title', 'href', 'ajax'))), + ); + + // @todo Reconcile Views usage of 'ajax' as a boolean with the rest of + // core's usage of it as an array. + if (isset($link['ajax']) && is_array($link['ajax'])) { + $link_element['#ajax'] = $link['ajax']; + } + // Handle links. if (isset($link['href'])) { $is_current_path = ($link['href'] == current_path() || ($link['href'] == '' && drupal_is_front_page())); @@ -1696,24 +1708,14 @@ function theme_links($variables) { if ($is_current_path && $is_current_language) { $class[] = 'active'; } - // @todo Reconcile Views usage of 'ajax' as a boolean with the rest of - // core's usage of it as an array. - if (isset($link['ajax']) && is_array($link['ajax'])) { - // To attach Ajax behavior, render a link element, rather than just - // call l(). - $link_element = array( - '#type' => 'link', - '#title' => $link['title'], - '#href' => $link['href'], - '#ajax' => $link['ajax'], - '#options' => array_diff_key($link, drupal_map_assoc(array('title', 'href', 'ajax'))), - ); - $item = drupal_render($link_element); - } - else { - // Pass in $link as $options, they share the same keys. - $item = l($link['title'], $link['href'], $link); - } + + $link_element['#href'] = $link['href']; + $item = drupal_render($link_element); + } + elseif (isset($link['route_name'])) { + $link_element['#route_name'] = $link['route_name']; + $link_element['#route_parameters'] = empty($link['route_parameters']) ? array() : $link['route_parameters']; + $item = drupal_render($link_element); } // Handle title-only text items. else { diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php index bfbf5b0..5af190c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php @@ -186,19 +186,23 @@ public function adminOverview() { $links = array(); $links['edit'] = array( 'title' => $this->t('Edit'), - 'href' => "admin/config/services/aggregator/edit/feed/$feed->fid", + 'route_name' => 'aggregator.feed_edit', + 'route_parameters' => array('aggregator_feed' => $feed->fid), ); $links['delete'] = array( 'title' => $this->t('Delete'), - 'href' => "admin/config/services/aggregator/delete/feed/$feed->fid", + 'route_name' => 'aggregator.feed_delete', + 'route_parameters' => array('aggregator_feed' => $feed->fid), ); $links['remove'] = array( 'title' => $this->t('Remove items'), - 'href' => "admin/config/services/aggregator/remove/$feed->fid", + 'route_name' => 'aggregator.feed_items_delete', + 'route_parameters' => array('aggregator_feed' => $feed->fid), ); $links['update'] = array( 'title' => $this->t('Update items'), - 'href' => "admin/config/services/aggregator/update/$feed->fid", + 'route_name' => 'aggregator.feed_refresh', + 'route_parameters' => array('aggregator_feed' => $feed->fid), 'query' => array('token' => drupal_get_token("aggregator/update/$feed->fid")), ); $row[] = array( @@ -228,11 +232,13 @@ public function adminOverview() { $links = array(); $links['edit'] = array( 'title' => $this->t('Edit'), - 'href' => "admin/config/services/aggregator/edit/category/$category->cid", + 'route_name' => 'aggregator.category_admin_edit', + 'route_parameters' => array('cid' => $category->cid), ); $links['delete'] = array( 'title' => $this->t('Delete'), - 'href' => "admin/config/services/aggregator/delete/category/$category->cid", + 'route_name' => 'aggregator.category_delete', + 'route_parameters' => array('cid' => $category->cid), ); $row[] = array( 'data' => array( diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php index c47bdcc..4aadec0 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php @@ -63,7 +63,8 @@ public function buildForm(array $form, array &$form_state, $default_ip = '') { $links = array(); $links['delete'] = array( 'title' => $this->t('delete'), - 'href' => "admin/config/people/ban/delete/$ip->iid", + 'route_name' => 'ban.delete', + 'route_parameters' => array('ban_id' => $ip->iid), ); $row[] = array( 'data' => array( diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc index 1d7061b..0ffefc5 100644 --- a/core/modules/book/book.admin.inc +++ b/core/modules/book/book.admin.inc @@ -53,12 +53,14 @@ function theme_book_admin_table($variables) { if ($access) { $links['edit'] = array( 'title' => t('Edit'), - 'href' => "node/$nid/edit", + 'route_name' => 'node.page_edit', + 'route_parameters' => array('node' => $nid), 'query' => $destination, ); $links['delete'] = array( 'title' => t('Delete'), - 'href' => "node/$nid/delete", + 'route_name' => 'node.delete_confirm', + 'route_parameters' => array('node' => $nid), 'query' => $destination, ); } diff --git a/core/modules/book/lib/Drupal/book/Controller/BookController.php b/core/modules/book/lib/Drupal/book/Controller/BookController.php index 214a801..b9920d2 100644 --- a/core/modules/book/lib/Drupal/book/Controller/BookController.php +++ b/core/modules/book/lib/Drupal/book/Controller/BookController.php @@ -77,7 +77,8 @@ public function adminOverview() { $links = array(); $links['edit'] = array( 'title' => t('Edit order and titles'), - 'href' => 'admin/structure/book/' . $book['nid'], + 'route_name' => 'book.admin_edit', + 'route_parameters' => array('node' => $book['nid']), ); $row[] = array( 'data' => array( diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 02f2278..c4360dc 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -156,13 +156,16 @@ function comment_admin_overview($form, &$form_state, $arg) { $links = array(); $links['edit'] = array( 'title' => t('edit'), - 'href' => 'comment/' . $comment->id() . '/edit', + 'route_name' => 'comment.edit_page', + 'route_parameters' => array('comment' => $comment->id()), 'query' => $destination, ); if (module_invoke('content_translation', 'translate_access', $comment)) { $links['translate'] = array( 'title' => t('translate'), 'href' => 'comment/' . $comment->id() . '/translations', + 'route_name' => 'content_translation.translation_overview_comment', + 'route_parameters' => array('comment' => $comment->id()), 'query' => $destination, ); }