src/View/Helper/Decorator/Decorator.php
protected function prepare($markup, $decorators)
    {
        $param_arr = func_get_args();
        if (is_array($decorators)) {
            $param_arr[1] = new \ArrayObject($decorators);
        }

        $order = 0;
        $sortAux = [];

        foreach ($param_arr[1] as $decorator => $options) {
            if (!is_string($decorator) && is_string($options)) {
                $param_arr[1][$options] = [];
                continue;
            } elseif (is_callable($options)) {
                $options = call_user_func_array($options, $param_arr);
                $param_arr[1][$decorator] = $options;
            }

            if (!is_array($options)) {
                continue;
            }

            if (!isset($options['order'])) {
                $plugin = $this->getDecoratorHelper(
                    empty($options['type']) ? $decorator : $options['type']
                );

                if ($plugin instanceof OrderedDecoratorInterface) {
                    $order = $plugin->getOrder();
                }

                $options['order'] = $order;
            } else {
                $order = (int) $options['order'];
            }

            $sortAux[] = $options['order'];
            $order += $this->orderStep;
        }

        $param_arr[1] = ArrayUtils::iteratorToArray($param_arr[1]);
        $param_arr[1] = array_filter($param_arr[1], 'is_array');
        array_multisort($sortAux, SORT_ASC, SORT_NUMERIC, $param_arr[1]);

        return $param_arr[1];
    }
protected function prepare($markup, $decorators)
    {
        $param_arr = func_get_args();
        if (is_array($decorators)) {
            $param_arr[1] = new \ArrayObject($decorators);
        }

        $order = 0;
        $sortAux = [];

        foreach ($param_arr[1] as $decorator => $options) {
            if (!is_string($decorator) && is_string($options)) {
                $param_arr[1][$options] = [];
                continue;
            } elseif (is_callable($options)) {
                $options = call_user_func_array($options, $param_arr);
                $param_arr[1][$decorator] = $options;
            }

            if (!is_array($options)) {
                continue;
            }

            if (!isset($options['order'])) {
                $plugin = $this->getDecoratorHelper(
                    empty($options['type']) ? $decorator : $options['type']
                );

                if ($plugin instanceof OrderedDecoratorInterface) {
                    $order = $plugin->getOrder();
                }

                $options['order'] = $order;
            } else {
                $order = (int) $options['order'];
            }

            $sortAux[] = $options['order'];
            $order += $this->orderStep;
        }

        $param_arr[1] = ArrayUtils::iteratorToArray($param_arr[1]);
        $param_arr[1] = array_filter($param_arr[1], 'is_array');
        array_multisort($sortAux, SORT_ASC, SORT_NUMERIC, $param_arr[1]);

        return $param_arr[1];
    }
protected function prepare ( $ markup , $ decorators ) { $ param_arr = func_get_args ( ) ; if ( is_array ( $ decorators ) ) { $ param_arr [ 1 ] = new \ ArrayObject ( $ decorators ) ; } $ order = 0 ; $ sortAux = [ ] ; foreach ( $ param_arr [ 1 ] as $ decorator => $ options ) { if ( ! is_string ( $ decorator ) && is_string ( $ options ) ) { $ param_arr [ 1 ] [ $ options ] = [ ] ; continue ; } elseif ( is_callable ( $ options ) ) { $ options = call_user_func_array ( $ options , $ param_arr ) ; $ param_arr [ 1 ] [ $ decorator ] = $ options ; } if ( ! is_array ( $ options ) ) { continue ; } if ( ! isset ( $ options [ 'order' ] ) ) { $ plugin = $ this -> getDecoratorHelper ( empty ( $ options [ 'type' ] ) ? $ decorator : $ options [ 'type' ] ) ; if ( $ plugin instanceof OrderedDecoratorInterface ) { $ order = $ plugin -> getOrder ( ) ; } $ options [ 'order' ] = $ order ; } else { $ order = ( int ) $ options [ 'order' ] ; } $ sortAux [ ] = $ options [ 'order' ] ; $ order += $ this -> orderStep ; } $ param_arr [ 1 ] = ArrayUtils :: iteratorToArray ( $ param_arr [ 1 ] ) ; $ param_arr [ 1 ] = array_filter ( $ param_arr [ 1 ] , 'is_array' ) ; array_multisort ( $ sortAux , SORT_ASC , SORT_NUMERIC , $ param_arr [ 1 ] ) ; return $ param_arr [ 1 ] ; }
Sorts decorators according to 'order' option

@param string $markup
@param array|\Traversable $decorators
@return array
Sorts decorators according to order option