Example #1
0
 /**
  * @param $label
  * @return string
  */
 protected function createSortableLink($label)
 {
     $direction = $this->getNextSortDirection();
     $currentDirection = $this->getCurrentSortDirection();
     $limit = $this->table->getItemsPerPageIdentifier();
     $sortValues = [$this->table->getSortQueryStringKey() => $this->sortableName, $this->table->getSortDirectionQueryStringKey() => $direction, $this->table->getPagingIdentifier() => $this->table->getCurrentPage(), $limit => array_get($this->table->getInput(), $limit)];
     $qs = http_build_query(array_merge($this->table->getInput(), $sortValues));
     $url = $this->table->getBaseUrl() . '?' . $qs;
     $icon = '';
     $asc = '<i class="fa fa-chevron-up"></i>';
     $desc = '<i class="fa fa-chevron-down"></i>';
     if ($this->isBeingSorted()) {
         if ($currentDirection == self::SORT_ASCENDING) {
             $icon = $asc;
         }
         if ($currentDirection == self::SORT_DESCENDING) {
             $icon = $desc;
         }
     }
     return sprintf('<a href="%s" class="grid-view-sort-%s">%s %s</a>', $url, $currentDirection, $icon, $label);
 }