Commit c9b5abc5 authored by alexpott's avatar alexpott

Issue #1974370 by kim.pepper: Convert aggregator_page_last() to a Controller.

parent 0aadc79b
......@@ -134,10 +134,8 @@ function aggregator_menu() {
);
$items['aggregator'] = array(
'title' => 'Feed aggregator',
'page callback' => 'aggregator_page_last',
'access arguments' => array('access news feeds'),
'weight' => 5,
'file' => 'aggregator.pages.inc',
'route_name' => 'aggregator_page_last',
);
$items['aggregator/sources'] = array(
'title' => 'Sources',
......
......@@ -8,22 +8,6 @@
use Drupal\aggregator\Plugin\Core\Entity\Feed;
use Drupal\Core\Entity\EntityInterface;
/**
* Page callback: Displays the most recent items gathered from any feed.
*
* @return string
* The rendered list of items for the feed.
*
* @see aggregator_menu()
*/
function aggregator_page_last() {
drupal_add_feed('aggregator/rss', config('system.site')->get('name') . ' ' . t('aggregator'));
$items = aggregator_load_feed_items('sum');
return _aggregator_page_list($items, arg(1));
}
/**
* Page callback: Displays all the items captured from the particular feed.
*
......
......@@ -46,3 +46,10 @@ aggregator_opml_add:
_form: '\Drupal\aggregator\Form\OpmlFeedAdd'
requirements:
_permission: 'administer news feeds'
aggregator_page_last:
pattern: '/aggregator'
defaults:
_controller: '\Drupal\aggregator\Routing\AggregatorController::pageLast'
requirements:
_permission: 'access news feeds'
......@@ -7,14 +7,16 @@
namespace Drupal\aggregator\Routing;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Drupal\aggregator\FeedInterface;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\ControllerInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityManager;
use Drupal\aggregator\FeedInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
/**
* Returns responses for aggregator module routes.
......@@ -35,6 +37,20 @@ class AggregatorController implements ControllerInterface {
*/
protected $database;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactory
*/
protected $configFactory;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs a \Drupal\aggregator\Routing\AggregatorController object.
*
......@@ -42,10 +58,16 @@ class AggregatorController implements ControllerInterface {
* The Entity manager.
* @param \Drupal\Core\Database\Connection $database
* The database connection.
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(EntityManager $entity_manager, Connection $database) {
public function __construct(EntityManager $entity_manager, Connection $database, ConfigFactory $config_factory, ModuleHandlerInterface $module_handler) {
$this->entityManager = $entity_manager;
$this->database = $database;
$this->configFactory = $config_factory;
$this->moduleHandler = $module_handler;
}
/**
......@@ -54,7 +76,9 @@ public function __construct(EntityManager $entity_manager, Connection $database)
public static function create(ContainerInterface $container) {
return new static(
$container->get('plugin.manager.entity'),
$container->get('database')
$container->get('database'),
$container->get('config.factory'),
$container->get('module_handler')
);
}
......@@ -185,4 +209,22 @@ public function adminOverview() {
return $build;
}
/**
* Displays the most recent items gathered from any feed.
*
* @return string
* The rendered list of items for the feed.
*/
public function pageLast() {
drupal_add_feed('aggregator/rss', $this->configFactory->get('system.site')->get('name') . ' ' . t('aggregator'));
// @todo Refactor this function once after all controller conversions are
// done.
$this->moduleHandler->loadInclude('aggregator', 'inc', 'aggregator.pages');
$items = aggregator_load_feed_items('sum');
// @todo Refactor this function once after all controller conversions are
// done.
return _aggregator_page_list($items, arg(1));
}
}
......@@ -91,6 +91,11 @@ public function testFeedPage() {
$feed = $this->createFeed();
$this->updateFeedItems($feed, 30);
// Check for presence of an aggregator pager.
$this->drupalGet('aggregator');
$elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager'));
$this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
// Check for the presence of a pager.
$this->drupalGet('aggregator/sources/' . $feed->id());
$elements = $this->xpath("//ul[@class=:class]", array(':class' => 'pager'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment