public function NewTopicsBlock::build

Builds and returns the renderable array for this block plugin.

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockRenderController

File

drupal/core/modules/forum/lib/Drupal/forum/Plugin/Block/NewTopicsBlock.php, line 27
Contains \Drupal\forum\Plugin\Block\NewTopicsBlock.

Class

NewTopicsBlock
Provides a 'New forum topics' block.

Namespace

Drupal\forum\Plugin\Block

Code

public function build() {
  $query = db_select('forum_index', 'f')
    ->fields('f')
    ->addTag('node_access')
    ->addMetaData('base_table', 'forum_index')
    ->orderBy('f.created', 'DESC')
    ->range(0, $this->configuration['block_count']);
  return array(
    drupal_render_cache_by_query($query, 'forum_block_view'),
  );
}