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() {
$id = $this
->getPluginId();
if ($category = db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = :cid', array(
':cid' => $id,
))
->fetchObject()) {
$result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = :cid ORDER BY i.timestamp DESC, i.iid DESC', 0, $this->configuration['block_count'], array(
':cid' => $category->cid,
));
$read_more = theme('more_link', array(
'url' => 'aggregator/categories/' . $category->cid,
'title' => t("View this category'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,
);
}
return array();
}
}