NewTopicsBlock.php in Drupal 8
Same filename and directory in other branches
Namespace
Drupal\forum\Plugin\BlockFile
core/modules/forum/src/Plugin/Block/NewTopicsBlock.phpView source
<?php
namespace Drupal\forum\Plugin\Block;
use Drupal\Core\Database\Database;
/**
* Provides a 'New forum topics' block.
*
* @Block(
* id = "forum_new_block",
* admin_label = @Translation("New forum topics"),
* category = @Translation("Lists (Views)")
* )
*/
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
Name | Description |
---|---|
NewTopicsBlock | Provides a 'New forum topics' block. |