diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Routing/AggregatorController.php index aa94004..c8695fe 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\Core\ControllerInterface; +use Drupal\Core\Config\ConfigFactory; +use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityManager; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Returns responses for aggregator module routes. @@ -24,20 +26,44 @@ class AggregatorController implements ControllerInterface { protected $entityManager; /** + * The database connection. + * + * @var \Drupal\Core\Database\Connection + */ + protected $database; + + /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactory + */ + protected $configFactory; + + /** * Constructs a \Drupal\aggregator\Routing\AggregatorController object. * * @param \Drupal\Core\Entity\EntityManager $entity_manager * The Entity manager. + * @param \Drupal\Core\Database\Connection $database + * The database connection. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The config factory. */ - public function __construct(EntityManager $entity_manager) { + public function __construct(EntityManager $entity_manager, Connection $database, ConfigFactory $config_factory) { $this->entityManager = $entity_manager; + $this->database = $database; + $this->configFactory = $config_factory; } /** * {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('database'), + $container->get('config.factory') + ); } /** @@ -67,19 +93,19 @@ 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'); + $result = $this->database->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'); + $aggregator_summary_items = $this->configFactory->get('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'); + $summary_items = $this->entityManager->getRenderController('aggregator_item')->viewMultiple($items, 'summary'); } } $category->url = url('aggregator/categories/' . $category->cid);