Marcelgwerder\ApiHandler\Parser::parseSort PHP Метод

parseSort() защищенный Метод

A descending sort has a leading "-". Apply it to the query.
protected parseSort ( string $sortParam ) : void
$sortParam string
Результат void
    protected function parseSort($sortParam)
    {
        foreach (explode(',', $sortParam) as $sortElem) {
            //Check if ascending or derscenting(-) sort
            if (preg_match('/^-.+/', $sortElem)) {
                $direction = 'desc';
            } else {
                $direction = 'asc';
            }
            $pair = [preg_replace('/^-/', '', $sortElem), $direction];
            //Only add the sorts that are on the base resource
            if (strpos($sortElem, '.') === false) {
                call_user_func_array([$this->query, 'orderBy'], $pair);
            } else {
                $this->additionalSorts[] = $pair;
            }
        }
    }