Version 1
[yaffs-website] / web / core / modules / forum / src / Plugin / Block / NewTopicsBlock.php
diff --git a/web/core/modules/forum/src/Plugin/Block/NewTopicsBlock.php b/web/core/modules/forum/src/Plugin/Block/NewTopicsBlock.php
new file mode 100644 (file)
index 0000000..d57628f
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\forum\Plugin\Block;
+
+/**
+ * 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 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']);
+  }
+
+}