public static function findRoute($route, $properties = [])
    {
        // Check if properties for dynamic routing are given.
        if (! empty($properties)) {

            // Loop through all the created routes
            foreach (self::$routes as $r) {

                // Check if the given route name is equal to the route in the current loop.
                if ($r['props']['as'] == $route) {

                    // Divide the url in different parts by exploding on a '/'.
                    $parts = explode('/', $r['url']);
                    $url = "";  // Creates empty string to put in the dynamic url.
                    $count = 1; // Create a counter to check if reached the last piece of the url.
                    foreach ($parts as $part) {

                        // Check if the current piece is a dynamic piece.
                        if (substr($part, 0, 1) == '{' && substr($part, -1, 1) == '}') {
                            $prop = str_replace('}', '', str_replace('{', '', $part));

                            // Get the needed property and add it to the url
                            $url .= (count($parts) == $count ? $properties[$prop] : $properties[$prop]."/");
                        } else {
                            $url .= (count($parts) == $count ? $part : $part."/");
                        }
                        $count++;
                    }
                    return ($url == '/' ? $url : "/{$url}");
                }
            }
        }

        foreach (self::$routes as $r) {
            if ($r['props']['as'] == $route) {
                return ($r['url'] == '/' ? $r['url'] : "/{$r['url']}");
            }
        }
        throw new RouteNotFoundException($route);
    }
public static function findRoute($route, $properties = [])
    {
        // Check if properties for dynamic routing are given.
        if (! empty($properties)) {

            // Loop through all the created routes
            foreach (self::$routes as $r) {

                // Check if the given route name is equal to the route in the current loop.
                if ($r['props']['as'] == $route) {

                    // Divide the url in different parts by exploding on a '/'.
                    $parts = explode('/', $r['url']);
                    $url = "";  // Creates empty string to put in the dynamic url.
                    $count = 1; // Create a counter to check if reached the last piece of the url.
                    foreach ($parts as $part) {

                        // Check if the current piece is a dynamic piece.
                        if (substr($part, 0, 1) == '{' && substr($part, -1, 1) == '}') {
                            $prop = str_replace('}', '', str_replace('{', '', $part));

                            // Get the needed property and add it to the url
                            $url .= (count($parts) == $count ? $properties[$prop] : $properties[$prop]."/");
                        } else {
                            $url .= (count($parts) == $count ? $part : $part."/");
                        }
                        $count++;
                    }
                    return ($url == '/' ? $url : "/{$url}");
                }
            }
        }

        foreach (self::$routes as $r) {
            if ($r['props']['as'] == $route) {
                return ($r['url'] == '/' ? $r['url'] : "/{$r['url']}");
            }
        }
        throw new RouteNotFoundException($route);
    }
public static function findRoute ( $ route , $ properties = [ ] ) { // Check if properties for dynamic routing are given. if ( ! empty ( $ properties ) ) { // Loop through all the created routes foreach ( self :: $ routes as $ r ) { // Check if the given route name is equal to the route in the current loop. if ( $ r [ 'props' ] [ 'as' ] == $ route ) { // Divide the url in different parts by exploding on a '/'. $ parts = explode ( '/' , $ r [ 'url' ] ) ; $ url = "" ; // Creates empty string to put in the dynamic url. $ count = 1 ; // Create a counter to check if reached the last piece of the url. foreach ( $ parts as $ part ) { // Check if the current piece is a dynamic piece. if ( substr ( $ part , 0 , 1 ) == '{' && substr ( $ part , - 1 , 1 ) == '}' ) { $ prop = str_replace ( '}' , '' , str_replace ( '{' , '' , $ part ) ) ; // Get the needed property and add it to the url $ url .= ( count ( $ parts ) == $ count ? $ properties [ $ prop ] : $ properties [ $ prop ] . "/" ) ; } else { $ url .= ( count ( $ parts ) == $ count ? $ part : $ part . "/" ) ; } $ count ++ ; } return ( $ url == '/' ? $ url : "/{$url}" ) ; } } } foreach ( self :: $ routes as $ r ) { if ( $ r [ 'props' ] [ 'as' ] == $ route ) { return ( $ r [ 'url' ] == '/' ? $ r [ 'url' ] : "/{$r['url']}" ) ; } } throw new RouteNotFoundException ( $ route ) ; }
Finds a route by the given route name.
Also takes properties to put into the route url.

@param $route
@param array $properties
@return string
Finds a route by the given route name . Also takes properties to put into the route url .