function ForumManager::getTopicOrder
Same name in other branches
- 9 core/modules/forum/src/ForumManager.php \Drupal\forum\ForumManager::getTopicOrder()
- 10 core/modules/forum/src/ForumManager.php \Drupal\forum\ForumManager::getTopicOrder()
- 11.x 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:
- ForumManager::NEWEST_FIRST: Date - newest first.
- ForumManager::OLDEST_FIRST: Date - oldest first.
- ForumManager::MOST_POPULAR_FIRST: Posts with the most comments first.
- ForumManager::LEAST_POPULAR_FIRST: Posts with the least comments first.
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 302
Class
- ForumManager
- Provides forum manager service.
Namespace
Drupal\forumCode
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',
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.