diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 416571d..4bdf890 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -153,12 +153,7 @@ function aggregator_menu() { 'file' => 'aggregator.pages.inc', ); $items['aggregator/categories/%aggregator_category'] = array( - 'title callback' => '_aggregator_category_title', - 'title arguments' => array(2), - 'page callback' => 'aggregator_page_category', - 'page arguments' => array(2), - 'access arguments' => array('access news feeds'), - 'file' => 'aggregator.pages.inc', + 'route_name' => 'aggregator_category', ); $items['aggregator/categories/%aggregator_category/view'] = array( 'title' => 'View', @@ -233,19 +228,6 @@ function aggregator_menu() { } /** - * Title callback: Returns a title for aggregator category pages. - * - * @param $category - * An aggregator category. - * - * @return - * A string with the aggregator category title. - */ -function _aggregator_category_title($category) { - return $category->title; -} - -/** * Implements hook_permission(). */ function aggregator_permission() { diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index ca8ecad..18a5684 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -53,7 +53,7 @@ function aggregator_page_source_form($form, $form_state, $feed) { * The category for which to list all of the aggregated items. * * @return string - * The rendered list of items for the feed. + * The render array with list of items for the feed. * * @see aggregator_menu() * @ingroup forms @@ -65,7 +65,7 @@ function aggregator_page_category($category) { // database by aggregator_category_load(). $items = aggregator_load_feed_items('category', $category); - return _aggregator_page_list($items, arg(3)); + return _aggregator_page_list($items, $category->cid); } /** diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index 2c69045..18d2a29 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -67,3 +67,10 @@ aggregator_categories: _content: '\Drupal\aggregator\Controller\AggregatorController::categories' requirements: _access_aggregator_categories: 'TRUE' + +aggregator_category: + pattern: '/aggregator/categories/{cid}' + defaults: + _content: '\Drupal\aggregator\Controller\AggregatorController::category' + requirements: + _permission: 'access news feeds' diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php index a8b1d80..08aeb6a 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php @@ -323,4 +323,23 @@ public function sources() { return $build; } + /** + * Displays feed items aggregated in a category. + * + * @param int $cid + * The category id for which to list all of the aggregated items. + * + * @return array + * The render array with list of items for the feed. + */ + public function category($cid) { + $category = $this->database->query('SELECT cid, title FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $cid))->fetchObject(); + drupal_set_title($category->title); + + // @todo move included functions to controller. + module_load_include('inc', 'aggregator', 'aggregator.pages'); + + return aggregator_page_category($category); + } + }