You are here

protected function ForumManager::getTopicOrder in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/forum/src/ForumManager.php \Drupal\forum\ForumManager::getTopicOrder()
  2. 10 core/modules/forum/src/ForumManager.php \Drupal\forum\ForumManager::getTopicOrder()

Gets topic sorting information based on an integer code.

Parameters

int $sortby: One of the following integers indicating the sort criteria:

Return value

array An array with the following values:

  • field: A field for an SQL query.
  • sort: 'asc' or 'desc'.
1 call to ForumManager::getTopicOrder()
ForumManager::getTopics in core/modules/forum/src/ForumManager.php
Gets list of forum topics.

File

core/modules/forum/src/ForumManager.php, line 293

Class

ForumManager
Provides forum manager service.

Namespace

Drupal\forum

Code

protected function getTopicOrder($sortby) {
  switch ($sortby) {
    case static::NEWEST_FIRST:
      return [
        'field' => 'f.last_comment_timestamp',
        'sort' => 'desc',
      ];
    case static::OLDEST_FIRST:
      return [
        'field' => 'f.last_comment_timestamp',
        'sort' => 'asc',
      ];
    case static::MOST_POPULAR_FIRST:
      return [
        'field' => 'f.comment_count',
        'sort' => 'desc',
      ];
    case static::LEAST_POPULAR_FIRST:
      return [
        'field' => 'f.comment_count',
        'sort' => 'asc',
      ];
  }
}