public function returnMiddleware(App $app, array $objects, array $middleware)
    {
        if (isset($middleware['arguments'])) {
            $params = $middleware['arguments'];
            $count = count($params);
        } else {
            $count = 0;
        }
        foreach ($params as $k => $v) {
            if (preg_match("#.#", $v)) {
                $explode = explode(".", $v);
                if (isset($objects[$explode[0]])) {
                    if (count($explode) >= 2) {
                        $param = $explode[1];
                        $params[$k] = $objects[$explode[0]]->$param;
                    } else {
                        $params[$k] = $objects[$explode[0]];
                    }
                }
            }
        }
        if (isset($middleware['middleware'])) {
            if ($count == 1) {
                return (new $middleware['middleware']($params[0]));
            } elseif ($count == 2) {
                return (new $middleware['middleware']($params[0], $params[1]));
            } else {
                return (new $middleware['middleware']());
            }
        } else {
            return ($params[0]);
        }
    }
public function returnMiddleware(App $app, array $objects, array $middleware)
    {
        if (isset($middleware['arguments'])) {
            $params = $middleware['arguments'];
            $count = count($params);
        } else {
            $count = 0;
        }
        foreach ($params as $k => $v) {
            if (preg_match("#.#", $v)) {
                $explode = explode(".", $v);
                if (isset($objects[$explode[0]])) {
                    if (count($explode) >= 2) {
                        $param = $explode[1];
                        $params[$k] = $objects[$explode[0]]->$param;
                    } else {
                        $params[$k] = $objects[$explode[0]];
                    }
                }
            }
        }
        if (isset($middleware['middleware'])) {
            if ($count == 1) {
                return (new $middleware['middleware']($params[0]));
            } elseif ($count == 2) {
                return (new $middleware['middleware']($params[0], $params[1]));
            } else {
                return (new $middleware['middleware']());
            }
        } else {
            return ($params[0]);
        }
    }
public function returnMiddleware ( App $ app , array $ objects , array $ middleware ) { if ( isset ( $ middleware [ 'arguments' ] ) ) { $ params = $ middleware [ 'arguments' ] ; $ count = count ( $ params ) ; } else { $ count = 0 ; } foreach ( $ params as $ k => $ v ) { if ( preg_match ( "#.#" , $ v ) ) { $ explode = explode ( "." , $ v ) ; if ( isset ( $ objects [ $ explode [ 0 ] ] ) ) { if ( count ( $ explode ) >= 2 ) { $ param = $ explode [ 1 ] ; $ params [ $ k ] = $ objects [ $ explode [ 0 ] ] -> $ param ; } else { $ params [ $ k ] = $ objects [ $ explode [ 0 ] ] ; } } } } if ( isset ( $ middleware [ 'middleware' ] ) ) { if ( $ count == 1 ) { return ( new $ middleware [ 'middleware' ] ( $ params [ 0 ] ) ) ; } elseif ( $ count == 2 ) { return ( new $ middleware [ 'middleware' ] ( $ params [ 0 ] , $ params [ 1 ] ) ) ; } else { return ( new $ middleware [ 'middleware' ] ( ) ) ; } } else { return ( $ params [ 0 ] ) ; } }
Limit of 2 params
@param App $app app slim object
@param array array $objects objects for arguments
@param array $middleware middleware infos
@return App $app app slim object
Limit of 2 params