diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index b544908..e1bbaca 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -155,9 +155,7 @@ function aggregator_menu() { ); $items['aggregator/categories'] = array( 'title' => 'Categories', - 'page callback' => 'aggregator_page_categories', - 'access callback' => '_aggregator_has_categories', - 'file' => 'aggregator.pages.inc', + 'route_name' => 'aggregator_categories', ); $items['aggregator/rss'] = array( 'title' => 'RSS feed', diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index 6248012..9951b53 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -368,41 +368,6 @@ function aggregator_page_sources() { } /** - * Page callback: Displays all the categories used by the Aggregator module. - * - * @return string - * An HTML formatted string. - * - * @see aggregator_menu() - */ -function aggregator_page_categories() { - $result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description'); - - $build = array( - '#type' => 'container', - '#attributes' => array('class' => array('aggregator-wrapper')), - '#sorted' => TRUE, - ); - $aggregator_summary_items = config('aggregator.settings')->get('source.list_max'); - foreach ($result as $category) { - $summary_items = array(); - if ($aggregator_summary_items) { - if ($items = aggregator_load_feed_items('category', $category, $aggregator_summary_items)) { - $summary_items = entity_view_multiple($items, 'summary'); - } - } - $category->url = url('aggregator/categories/' . $category->cid); - $build[$category->cid] = array( - '#theme' => 'aggregator_summary_items', - '#summary_items' => $summary_items, - '#source' => $category, - ); - } - - return $build; -} - -/** * Page callback: Generates an RSS 0.92 feed of aggregator items or categories. * * @return string diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index bf02d5c..d756689 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -25,3 +25,10 @@ aggregator_feed_add: _controller: '\Drupal\aggregator\Routing\AggregatorController::feedAdd' requirements: _permission: 'administer news feeds' + +aggregator_categories: + pattern: '/aggregator/categories' + defaults: + _controller: '\Drupal\aggregator\Routing\AggregatorController::categories' + requirements: + _permission: 'access news feeds' diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php index 66f1fbd..aa94004 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php @@ -56,4 +56,41 @@ public function feedAdd() { return entity_get_form($feed); } + /** + * Displays all the categories used by the Aggregator module. + * + * @return string + * An HTML formatted string. + */ + public function categories() { + + // TODO move included functions to controller. + module_load_include('inc', 'aggregator', 'aggregator.pages'); + + $result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description'); + + $build = array( + '#type' => 'container', + '#attributes' => array('class' => array('aggregator-wrapper')), + '#sorted' => TRUE, + ); + $aggregator_summary_items = config('aggregator.settings')->get('source.list_max'); + foreach ($result as $category) { + $summary_items = array(); + if ($aggregator_summary_items) { + if ($items = aggregator_load_feed_items('category', $category, $aggregator_summary_items)) { + $summary_items = entity_view_multiple($items, 'summary'); + } + } + $category->url = url('aggregator/categories/' . $category->cid); + $build[$category->cid] = array( + '#theme' => 'aggregator_summary_items', + '#summary_items' => $summary_items, + '#source' => $category, + ); + } + + return $build; + } + }