/** * Discovers className to process route * * Use this method in combination with `{@see \Apolo\SetRoutes}` method to * process the route and use the right controller. * * ```php * Apolo::setRoutes(array( * '/show/post/(:digit:)' => 'PostEditController', * )); * * Apolo::discover('/show/post/25'); // -> PostEditController * ``` * * @param string $uri Url to convert to controller ClassName * * @uses \Apolo\Core\Route * @internal * @public * @static * @return string */ public static function discover($uri) { $routes = Route::processedRoutes(); foreach ($routes as $regex => $className) { if (preg_match("/{$regex}/", $uri)) { return $className; } } }