You are here

protected function ForumManager::getTopicOrder in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 285
Contains \Drupal\forum\ForumManager.

Class

ForumManager
Provides forum manager service.

Namespace

Drupal\forum

Code

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