AttributeFilter::getMainAttributesForSearchFromQuery PHP Метод

getMainAttributesForSearchFromQuery() публичный Метод

public getMainAttributesForSearchFromQuery ( CHttpRequest $request, array $append = [] ) : array | mixed
$request CHttpRequest
$append array
Результат array | mixed
    public function getMainAttributesForSearchFromQuery(CHttpRequest $request, array $append = [])
    {
        $result = [];
        foreach ($this->getMainSearchParams() as $param => $field) {
            if ($request->getQuery($param)) {
                $result[$param] = $request->getQuery($param);
                if (is_array($result[$param])) {
                    if (isset($result[$param]['to']) && null == $result[$param]['to']) {
                        unset($result[$param]['to']);
                    }
                    if (isset($result[$param]['from']) && null == $result[$param]['from']) {
                        unset($result[$param]['from']);
                    }
                }
            }
        }
        if (!empty($append)) {
            $result = CMap::mergeArray($append, $result);
        }
        return $result;
    }

Usage Example

Пример #1
0
 /**
  * @param $path
  * @throws CHttpException
  */
 public function actionView($path)
 {
     $category = StoreCategory::model()->published()->findByPath($path);
     if (null === $category) {
         throw new CHttpException(404);
     }
     $data = Yii::app()->getRequest()->getQueryString() ? $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_CATEGORY => [$category->id]]), $this->attributeFilter->getTypeAttributesForSearchFromQuery(Yii::app()->getRequest())) : $this->productRepository->getListForCategory($category);
     $this->render('view', ['dataProvider' => $data, 'category' => $category]);
 }
All Usage Examples Of AttributeFilter::getMainAttributesForSearchFromQuery