You are here

protected function SortableViewsStyleTrait::retrieveSortOrder in Sortableviews 8

Returns the sort order as specified in display settings.

Return value

string "asc" or "desc" depending on the display settings.

1 call to SortableViewsStyleTrait::retrieveSortOrder()
SortableViewsStyleTrait::render in src/SortableViewsStyleTrait.php

File

src/SortableViewsStyleTrait.php, line 137

Class

SortableViewsStyleTrait
Provides sortable functionality for View styles.

Namespace

Drupal\sortableviews

Code

protected function retrieveSortOrder() {
  if (!empty($this->view->sort)) {
    foreach ($this->view->sort as $sort) {
      if (isset($sort->definition['field_name']) && $sort->definition['field_name'] == $this->options['weight_field'] && $sort->options['order'] == 'DESC') {
        return 'desc';
      }
    }
  }
  return 'asc';
}