NewTopicsBlock.php

Same filename in other branches
  1. 9 core/modules/forum/src/Plugin/Block/NewTopicsBlock.php
  2. 8.9.x core/modules/forum/src/Plugin/Block/NewTopicsBlock.php
  3. 10 core/modules/forum/src/Plugin/Block/NewTopicsBlock.php

Namespace

Drupal\forum\Plugin\Block

File

core/modules/forum/src/Plugin/Block/NewTopicsBlock.php

View source
<?php

namespace Drupal\forum\Plugin\Block;

use Drupal\Core\Block\Attribute\Block;
use Drupal\Core\Database\Database;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides a 'New forum topics' block.
 */
class NewTopicsBlock extends ForumBlockBase {
    
    /**
     * {@inheritdoc}
     */
    protected function buildForumQuery() {
        return Database::getConnection()->select('forum_index', 'f')
            ->fields('f')
            ->addTag('node_access')
            ->addMetaData('base_table', 'forum_index')
            ->orderBy('f.created', 'DESC')
            ->range(0, $this->configuration['block_count']);
    }

}

Classes

Title Deprecated Summary
NewTopicsBlock Provides a 'New forum topics' block.

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