Builds and returns the renderable array for this block plugin.
array A renderable array representing the content of the block.
Overrides BlockPluginInterface::build
\Drupal\block\BlockRenderController
public function build() {
// Plugin IDs look something like this: aggregator_feed_block:1.
list(, $id) = explode(':', $this
->getPluginId());
if ($feed = db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = :fid', array(
':fid' => $id,
))
->fetchObject()) {
$result = db_query_range("SELECT * FROM {aggregator_item} WHERE fid = :fid ORDER BY timestamp DESC, iid DESC", 0, $this->configuration['block_count'], array(
':fid' => $id,
));
$read_more = theme('more_link', array(
'url' => 'aggregator/sources/' . $feed->fid,
'title' => t("View this feed's recent news."),
));
$items = array();
foreach ($result as $item) {
$items[] = theme('aggregator_block_item', array(
'item' => $item,
));
}
// Only display the block if there are items to show.
if (count($items) > 0) {
return array(
'#children' => theme('item_list', array(
'items' => $items,
)) . $read_more,
);
}
}
}