public function getClosure($app)
    {    
        // Confirm the matched property is a key in the routes array
        if (!isset($this->routes[$this->matched]))
            return false;
        
        $callback = $this->routes[$this->matched];
        
        // Is the callback a string? If so, it should be the name of a resource 
        // class, which will be used to build the logic inside a closure.
        if (is_string($callback)) {
            $className = 'Resources\\' . $callback;
            if (class_exists($className)) {
                // Success, so lets build a closure for executing the 
                // requested resource's output
                $callback = function() use ($app, $className, $callback) {
                    // Does this resource have a IoC alias registered?
                    if (!$resource = $app->get($callback))
                        $resource = new $className(
                            $app->get('request'), 
                            $app->get('response')
                        );
                    
                    $resource->output();
                };

            } else {
                // Oops, bad class name given to the router
                return false;
            }
        }
        
        // $callback should now be a closure - either because that's what the 
        // router was given originally, or because one was built from the 
        // string it was given.
        if (is_callable($callback)) {
            return $callback;
        } else {
            // The callback wasn't callable (that's not good).
            return false;
        }
    }
public function getClosure($app)
    {    
        // Confirm the matched property is a key in the routes array
        if (!isset($this->routes[$this->matched]))
            return false;
        
        $callback = $this->routes[$this->matched];
        
        // Is the callback a string? If so, it should be the name of a resource 
        // class, which will be used to build the logic inside a closure.
        if (is_string($callback)) {
            $className = 'Resources\\' . $callback;
            if (class_exists($className)) {
                // Success, so lets build a closure for executing the 
                // requested resource's output
                $callback = function() use ($app, $className, $callback) {
                    // Does this resource have a IoC alias registered?
                    if (!$resource = $app->get($callback))
                        $resource = new $className(
                            $app->get('request'), 
                            $app->get('response')
                        );
                    
                    $resource->output();
                };

            } else {
                // Oops, bad class name given to the router
                return false;
            }
        }
        
        // $callback should now be a closure - either because that's what the 
        // router was given originally, or because one was built from the 
        // string it was given.
        if (is_callable($callback)) {
            return $callback;
        } else {
            // The callback wasn't callable (that's not good).
            return false;
        }
    }
public function getClosure ( $ app ) { // Confirm the matched property is a key in the routes array if ( ! isset ( $ this -> routes [ $ this -> matched ] ) ) return false ; $ callback = $ this -> routes [ $ this -> matched ] ; // Is the callback a string? If so, it should be the name of a resource  // class, which will be used to build the logic inside a closure. if ( is_string ( $ callback ) ) { $ className = 'Resources\\' . $ callback ; if ( class_exists ( $ className ) ) { // Success, so lets build a closure for executing the  // requested resource's output $ callback = function ( ) use ( $ app , $ className , $ callback ) { // Does this resource have a IoC alias registered? if ( ! $ resource = $ app -> get ( $ callback ) ) $ resource = new $ className ( $ app -> get ( 'request' ) , $ app -> get ( 'response' ) ) ; $ resource -> output ( ) ; } ; } else { // Oops, bad class name given to the router return false ; } } // $callback should now be a closure - either because that's what the  // router was given originally, or because one was built from the  // string it was given. if ( is_callable ( $ callback ) ) { return $ callback ; } else { // The callback wasn't callable (that's not good). return false ; } }
Returns a Closure instance which contains the logic to generate the
output for the requested route, or false.

@param Application $app
@return \Closure|boolean
Returns a Closure instance which contains the logic to generate the output for the requested route or false .