Skip to content

Commit

Permalink
Add sortBy
Browse files Browse the repository at this point in the history
  • Loading branch information
iranianpep committed Sep 23, 2016
1 parent 73bf62f commit 7c2ab95
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/PhpTableGenerator/HeadCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ class HeadCell extends Cell
/**
* @var
*/
private $sortDir;
private $sortBy;

/**
* @var
*/
private $sortDirKey;

/**
* @var
*/
private $sortDir;

public function __construct($title = null, $alias = null, $content = null, $htmlspecialchars = false)
{
if ($title !== null) {
Expand Down Expand Up @@ -217,6 +222,22 @@ public function setSortDir($sortDir)
$this->sortDir = (strtolower($sortDir) === 'asc') ? 'asc' : 'desc';
}

/**
* @return string
*/
public function getSortBy()
{
return $this->sortBy;
}

/**
* @param string $sortBy
*/
public function setSortBy($sortBy)
{
$this->sortBy = $sortBy;
}

/**
* According the current sorting direction, alias, and etc return
* the next sorting direction
Expand All @@ -226,7 +247,7 @@ public function setSortDir($sortDir)
public function getNewSortDir()
{
$alias = $this->getAlias();
$sortBy = $this->getSortBy();
//$sortBy = $this->getSortBy();
$sortDir = $this->getSortDir();

return ($alias === $sortBy && $sortDir === 'asc') ? 'desc' : 'asc';
Expand Down

0 comments on commit 7c2ab95

Please sign in to comment.