public function apply(Source $source) { $this->initValue(); $options = $this->getOptions(); $value = $this->getValue(); if ($value == '') { return true; } if ($source instanceof Builder) { $data = $source->getData(); $this->_applySelectConditions($source); } else { throw new \Exception('Неизвестный тип источника данных'); } }
protected function _applySourceParams() { $sorted = false; if (isset($_GET[$this->getId()]) && is_array($_GET[$this->getId()])) { //Параметры грида $params = $_GET[$this->getId()]; if (isset($params['sortby']) && !empty($params['sortby'])) { $params['sortby'] = preg_replace('/[^A-Za-z0-9_-]+/', '', $params['sortby']); //sanitize input on column if ($this->_source->isSortable()) { $sortDir = $params['sortdir']; if (strtoupper($sortDir) != 'DESC') { $sortDir = 'ASC'; } else { $sortDir = 'DESC'; } $this->_source->order($params['sortby'], $sortDir); $sorted = true; } } } // default sort if (!$sorted && $this->_defaultSortColumn != null && $this->_source->isSortable()) { $this->_source->order($this->_defaultSortColumn, $this->_defaultSortDir); } }