public function RecentContentBlock::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/node/lib/Drupal/node/Plugin/Block/RecentContentBlock.php, line 64
Contains \Drupal\node\Plugin\Block\RecentContentBlock.

Class

RecentContentBlock
Provides a 'Recent content' block.

Namespace

Drupal\node\Plugin\Block

Code

public function build() {
  if ($nodes = node_get_recent($this->configuration['block_count'])) {
    return array(
      '#theme' => 'node_recent_block',
      '#nodes' => $nodes,
    );
  }
  else {
    return array(
      '#children' => t('No content available.'),
    );
  }
}