function ForumBlockBase::build

Same name and namespace in other branches
  1. 9 core/modules/forum/src/Plugin/Block/ForumBlockBase.php \Drupal\forum\Plugin\Block\ForumBlockBase::build()
  2. 10 core/modules/forum/src/Plugin/Block/ForumBlockBase.php \Drupal\forum\Plugin\Block\ForumBlockBase::build()
  3. 11.x core/modules/forum/src/Plugin/Block/ForumBlockBase.php \Drupal\forum\Plugin\Block\ForumBlockBase::build()

File

core/modules/forum/src/Plugin/Block/ForumBlockBase.php, line 20

Class

ForumBlockBase
Provides a base class for Forum blocks.

Namespace

Drupal\forum\Plugin\Block

Code

public function build() {
    $result = $this->buildForumQuery()
        ->execute();
    $elements = [];
    if ($node_title_list = node_title_list($result)) {
        $elements['forum_list'] = $node_title_list;
        $elements['forum_more'] = [
            '#type' => 'more_link',
            '#url' => Url::fromRoute('forum.index'),
            '#attributes' => [
                'title' => $this->t('Read the latest forum topics.'),
            ],
        ];
    }
    return $elements;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.