diff --git a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php index fcc2584..7fce4b3 100644 --- a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php @@ -15,6 +15,7 @@ use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\Core\Render\Renderer; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -51,6 +52,13 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt protected $itemQuery; /** + * Rendering service. + * + * @var \Drupal\Core\Render\Renderer + */ + protected $renderer; + + /** * Constructs an AggregatorFeedBlock object. * * @param array $configuration @@ -65,12 +73,15 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt * The entity storage for feed items. * @param \Drupal\Core\Entity\Query\QueryInterface $item_query * The entity query object for feed items. + * @param \Drupal\Core\Render\Renderer $renderer + * The renderer service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, FeedStorageInterface $feed_storage, ItemStorageInterface $item_storage, QueryInterface $item_query) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, FeedStorageInterface $feed_storage, ItemStorageInterface $item_storage, QueryInterface $item_query, Renderer $renderer) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->feedStorage = $feed_storage; $this->itemStorage = $item_storage; $this->itemQuery = $item_query; + $this->renderer = $renderer; } @@ -84,7 +95,8 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_definition, $container->get('entity.manager')->getStorage('aggregator_feed'), $container->get('entity.manager')->getStorage('aggregator_item'), - $container->get('entity.query')->get('aggregator_item') + $container->get('entity.query')->get('aggregator_item'), + $container->get('renderer') ); } @@ -161,7 +173,7 @@ public function build() { '#url' => $feed->urlInfo(), '#attributes' => array('title' => $this->t("View this feed's recent news.")), ); - $read_more = drupal_render($more_link); + $read_more = $this->renderer->render($more_link); $rendered_items = array(); foreach ($items as $item) { $aggregator_block_item = array( @@ -169,7 +181,7 @@ public function build() { '#url' => $item->urlInfo(), '#title' => $item->label(), ); - $rendered_items[] = drupal_render($aggregator_block_item); + $rendered_items[] = $this->renderer->render($aggregator_block_item); } // Only display the block if there are items to show. if (count($rendered_items) > 0) { @@ -178,7 +190,7 @@ public function build() { '#items' => $rendered_items, ); return array( - '#children' => drupal_render($item_list) . $read_more, + '#children' => $this->renderer->render($item_list) . $read_more, ); } }