/** * Fill array of Filter\Filter[] with values from $this->filter persistent parameter * Fill array of Column\Column[] with values from $this->sort persistent parameter * @return array $this->filters === Filter\Filter[] */ public function assableFilters() { foreach ($this->filter as $key => $value) { if (!isset($this->filters[$key])) { continue; } if (is_array($value) || $value instanceof \Traversable) { if (!ArraysHelper::testEmpty($value)) { $this->filters[$key]->setValue($value); } } else { if ($value !== '' && $value !== NULL) { $this->filters[$key]->setValue($value); } } } foreach ($this->columns as $column) { if (isset($this->sort[$column->getColumnName()])) { $column->setSort($this->sort); } } return $this->filters; }
/** * Sort data * @param Sorting $sorting * @return static */ public function sort(Sorting $sorting) { if (is_callable($sorting->getSortCallback())) { call_user_func($sorting->getSortCallback(), $this->data_source, $sorting->getSort()); return $this; } $sort = $sorting->getSort(); if (!empty($sort)) { foreach ($sort as $column => $order) { $this->data_source = $this->data_source->orderBy($column, $order); } } else { /** * Has the statement already a order by clause? */ $order = $this->data_source->getQueryBuilder()->getClause('order'); if (ArraysHelper::testEmpty($order)) { $this->data_source = $this->data_source->orderBy($this->primary_key); } } return $this; }
/** * Is filter active? * @return boolean */ public function isFilterActive() { $is_filter = ArraysHelper::testTruthy($this->filter); return $is_filter || $this->force_filter_active; }