/** * Ads orderBy to the current query in builder * * @param QueryBuilder $query * @param Model $model * @return void */ public function handleSorting(&$query, $model) { if ($this->Input->has('clearSort')) { $this->Manager->clearStack(); } if ($this->Input->has('multisort')) { $this->Manager->setIsMulti(true); } $sortStack = $this->Manager->getStack(); if ($this->Input->has('orderBy') || count($sortStack) > 0) { if (!$this->Input->has('multisort') && !$this->Manager->getIsMulti() && $this->Input->has('orderBy')) { $this->Manager->clearStack(); } $this->Manager->addToStack($this->Input->all()); $sortStack = $this->Manager->getStack(); foreach ($sortStack as $sort) { $query = $this->appendSort($query, $model, $sort); } } else { if (count($this->defaultOrderBy) > 0) { $query = $this->sortByDefault($query, $model); } } }
public function test_it_clears_stack() { $Framework = new \Devise\Support\Framework(); $Manager = new Manager($Framework); $Manager->clearStack(); }