public static function resource(){
        $arguments  = func_get_args();
        $path       = $arguments[0];
        $controller = end($arguments);

        $resourceRoutes = array(
            'get'           => array(
                'pattern'       => "$path",
                'method'        => 'get',
                'handler'       => "$controller:index"
            ),
            'get_paginate'  => array(
                'pattern'       => "$path/page/:page",
                'method'        => 'get',
                'handler'       => "$controller:index"
            ),
            'get_create'    => array(
                'pattern'       => "$path/create",
                'method'        => 'get',
                'handler'       => "$controller:create"
            ),
            'get_edit'      => array(
                'pattern'       => "$path/:id/edit",
                'method'        => 'get',
                'handler'       => "$controller:edit"
            ),
            'get_show'      => array(
                'pattern'       => "$path/:id",
                'method'        => 'get',
                'handler'       => "$controller:show"
            ),
            'post'          => array(
                'pattern'       => "$path",
                'method'        => 'post',
                'handler'       => "$controller:store"
            ),
            'put'           => array(
                'pattern'       => "$path/:id",
                'method'        => 'put',
                'handler'       => "$controller:update"
            ),
            'delete'        => array(
                'pattern'       => "$path/:id",
                'method'        => 'delete',
                'handler'       => "$controller:destroy"
            )
        );

        foreach ($resourceRoutes as $route) {
            $callable   = $arguments;

            //put edited pattern to the top stack
            array_shift($callable);
            array_unshift($callable, $route['pattern']);

            //put edited controller to the bottom stack
            array_pop($callable);
            array_push($callable, $route['handler']);

            call_user_func_array(array(self::$slim, $route['method']), $callable);
        }
    }
public static function resource(){
        $arguments  = func_get_args();
        $path       = $arguments[0];
        $controller = end($arguments);

        $resourceRoutes = array(
            'get'           => array(
                'pattern'       => "$path",
                'method'        => 'get',
                'handler'       => "$controller:index"
            ),
            'get_paginate'  => array(
                'pattern'       => "$path/page/:page",
                'method'        => 'get',
                'handler'       => "$controller:index"
            ),
            'get_create'    => array(
                'pattern'       => "$path/create",
                'method'        => 'get',
                'handler'       => "$controller:create"
            ),
            'get_edit'      => array(
                'pattern'       => "$path/:id/edit",
                'method'        => 'get',
                'handler'       => "$controller:edit"
            ),
            'get_show'      => array(
                'pattern'       => "$path/:id",
                'method'        => 'get',
                'handler'       => "$controller:show"
            ),
            'post'          => array(
                'pattern'       => "$path",
                'method'        => 'post',
                'handler'       => "$controller:store"
            ),
            'put'           => array(
                'pattern'       => "$path/:id",
                'method'        => 'put',
                'handler'       => "$controller:update"
            ),
            'delete'        => array(
                'pattern'       => "$path/:id",
                'method'        => 'delete',
                'handler'       => "$controller:destroy"
            )
        );

        foreach ($resourceRoutes as $route) {
            $callable   = $arguments;

            //put edited pattern to the top stack
            array_shift($callable);
            array_unshift($callable, $route['pattern']);

            //put edited controller to the bottom stack
            array_pop($callable);
            array_push($callable, $route['handler']);

            call_user_func_array(array(self::$slim, $route['method']), $callable);
        }
    }
public static function resource ( ) { $ arguments = func_get_args ( ) ; $ path = $ arguments [ 0 ] ; $ controller = end ( $ arguments ) ; $ resourceRoutes = array ( 'get' => array ( 'pattern' => "$path" , 'method' => 'get' , 'handler' => "$controller:index" ) , 'get_paginate' => array ( 'pattern' => "$path/page/:page" , 'method' => 'get' , 'handler' => "$controller:index" ) , 'get_create' => array ( 'pattern' => "$path/create" , 'method' => 'get' , 'handler' => "$controller:create" ) , 'get_edit' => array ( 'pattern' => "$path/:id/edit" , 'method' => 'get' , 'handler' => "$controller:edit" ) , 'get_show' => array ( 'pattern' => "$path/:id" , 'method' => 'get' , 'handler' => "$controller:show" ) , 'post' => array ( 'pattern' => "$path" , 'method' => 'post' , 'handler' => "$controller:store" ) , 'put' => array ( 'pattern' => "$path/:id" , 'method' => 'put' , 'handler' => "$controller:update" ) , 'delete' => array ( 'pattern' => "$path/:id" , 'method' => 'delete' , 'handler' => "$controller:destroy" ) ) ; foreach ( $ resourceRoutes as $ route ) { $ callable = $ arguments ; //put edited pattern to the top stack array_shift ( $ callable ) ; array_unshift ( $ callable , $ route [ 'pattern' ] ) ; //put edited controller to the bottom stack array_pop ( $ callable ) ; array_push ( $ callable , $ route [ 'handler' ] ) ; call_user_func_array ( array ( self :: $ slim , $ route [ 'method' ] ) , $ callable ) ; } }
Route resource to single controller
Route resource to single controller