diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 9755428..94a778f 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -200,12 +200,9 @@ function aggregator_menu() { 'file' => 'aggregator.admin.inc', ); $items['aggregator/sources/%aggregator_feed'] = array( - 'title callback' => 'entity_page_label', + 'title callback' => '_aggregator_page_label', 'title arguments' => array(2), - 'page callback' => 'aggregator_page_source', - 'page arguments' => array(2), - 'access arguments' => array('access news feeds'), - 'file' => 'aggregator.pages.inc', + 'route_name' => 'aggregator_page_source', ); $items['aggregator/sources/%aggregator_feed/view'] = array( 'title' => 'View', @@ -251,6 +248,26 @@ function aggregator_menu() { } /** + * Title callback: Returns a title for Aggregator feed view pages. + * + * @param int $fid + * Aggregator Feed Id for which to generate a label. + * @param $langcode + * (optional) The language code of the language that should be used for + * getting the label. If set to NULL, the entity's default language is + * used. + * + * @return + * The label of the Aggregator Feed, or NULL if there is no label defined. + * + * @see aggregator_menu() + */ +function _aggregator_page_label($fid, $langcode = NULL) { + $feed = aggregator_feed_load($fid); + return entity_page_label($feed, $langcode); +} + +/** * Title callback: Returns a title for aggregator category pages. * * @param $category diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index d4f1f6c..6a0fc57 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -32,3 +32,10 @@ aggregator_opml_add: _form: '\Drupal\aggregator\Form\OpmlFeedAdd' requirements: _permission: 'administer news feeds' + +aggregator_page_source: + pattern: 'aggregator/sources/{aggregator_feed}' + defaults: + _content: '\Drupal\aggregator\Routing\AggregatorController::viewFeed' + 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..a0bcca8 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php @@ -7,9 +7,11 @@ namespace Drupal\aggregator\Routing; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\aggregator\Plugin\Core\Entity\Feed; use Drupal\Core\ControllerInterface; use Drupal\Core\Entity\EntityManager; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Returns responses for aggregator module routes. @@ -24,20 +26,30 @@ class AggregatorController implements ControllerInterface { protected $entityManager; /** + * Module handler service. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** * Constructs a \Drupal\aggregator\Routing\AggregatorController object. * * @param \Drupal\Core\Entity\EntityManager $entity_manager * The Entity manager. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler class to use for invoking hooks. */ - public function __construct(EntityManager $entity_manager) { + public function __construct(EntityManager $entity_manager, ModuleHandlerInterface $module_handler) { $this->entityManager = $entity_manager; + $this->moduleHandler = $module_handler; } /** * {inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('plugin.manager.entity')); + return new static($container->get('plugin.manager.entity'), $container->get('module_handler')); } /** @@ -56,4 +68,22 @@ public function feedAdd() { return entity_get_form($feed); } + /** + * Displays all the items captured from the particular feed. + * + * @param \Drupal\aggregator\Plugin\Core\Entity\Feed $aggregator_feed + * The feed for which to display all items. + * + * @return string + * The rendered list of items for the feed. + */ + public function viewFeed(Feed $aggregator_feed = NULL) { + $this->moduleHandler->loadInclude('aggregator', 'pages.inc'); + $feed_source = $this->entityManager->getRenderController($aggregator_feed->entityType()) + ->view($aggregator_feed, 'default'); + // Load aggregator feed item for the particular feed id. + $items = aggregator_load_feed_items('source', $aggregator_feed); + // Print the feed items. + return _aggregator_page_list($items, arg(3), $feed_source); + } }