public static function findHandler($uri) { $uri_tokens = Request::parse_uri($uri); $test_path = '/' . implode('/', $uri_tokens); while ($test_path !== '') { Log::debug(__CLASS__ . ": Testing {$uri} against {$test_path}..."); if (!isset(self::$paths[$test_path])) { $test_path = strstr(substr($test_path, 1), '/') ? substr($test_path, 0, strrpos($test_path, '/')) : '/'; } else { return self::$paths[$test_path]['handler']; } if ($test_path === '/') { $test_path = ''; } } Log::debug(__CLASS__ . ": No handler found for uri {$uri}"); return false; }