src/SearchHelper.php
public static function buildSearchSortParameter(array $sorts)
    {
        if (empty($sorts)) {
            return '';
        }
        $sorting = [];
        foreach ($sorts as $sortField => $direction) {
            if (!self::validateFieldName((string) $sortField)) {
                throw new \LogicException(sprintf('Invalid field name "%s" for sorting field', $sortField));
            }
            if (!\in_array($direction, [true, 'desc', 'asc'], true)) {
                throw new \LogicException(sprintf('Wrong sorting direction "%s" for field "%s". Use either "desc", "asc"',
                    $direction, $sortField
                ));
            }

            // Only output the "desc" direction as "asc" is the default sorting
            $sorting[] = $sortField.('desc' === $direction ? ' '.$direction : '');
        }

        if (empty($sorting)) {
            return '';
        }

        return implode(',', $sorting);
    }
public static function buildSearchSortParameter(array $sorts)
    {
        if (empty($sorts)) {
            return '';
        }
        $sorting = [];
        foreach ($sorts as $sortField => $direction) {
            if (!self::validateFieldName((string) $sortField)) {
                throw new \LogicException(sprintf('Invalid field name "%s" for sorting field', $sortField));
            }
            if (!\in_array($direction, [true, 'desc', 'asc'], true)) {
                throw new \LogicException(sprintf('Wrong sorting direction "%s" for field "%s". Use either "desc", "asc"',
                    $direction, $sortField
                ));
            }

            // Only output the "desc" direction as "asc" is the default sorting
            $sorting[] = $sortField.('desc' === $direction ? ' '.$direction : '');
        }

        if (empty($sorting)) {
            return '';
        }

        return implode(',', $sorting);
    }
public static function buildSearchSortParameter ( array $ sorts ) { if ( empty ( $ sorts ) ) { return '' ; } $ sorting = [ ] ; foreach ( $ sorts as $ sortField => $ direction ) { if ( ! self :: validateFieldName ( ( string ) $ sortField ) ) { throw new \ LogicException ( sprintf ( 'Invalid field name "%s" for sorting field' , $ sortField ) ) ; } if ( ! \ in_array ( $ direction , [ true , 'desc' , 'asc' ] , true ) ) { throw new \ LogicException ( sprintf ( 'Wrong sorting direction "%s" for field "%s". Use either "desc", "asc"' , $ direction , $ sortField ) ) ; } // Only output the "desc" direction as "asc" is the default sorting $ sorting [ ] = $ sortField . ( 'desc' === $ direction ? ' ' . $ direction : '' ) ; } if ( empty ( $ sorting ) ) { return '' ; } return implode ( ',' , $ sorting ) ; }
Builds the "sort" parameter for the source image listing API endpoint.

The sort direction can either be: "asc", "desc" (or the boolean TRUE value, treated as "asc")

@param array $sorts The sorting options, as an associative array "field => sort-direction"

@return string
Builds the sort parameter for the source image listing API endpoint .