Beispiel #1
0
 /**
  * Automatically build routes for components.  This basically makes a
  * /:component/:controller/:action route for each component, or a
  * /:component/:action route if there is only one controller.
  *
  * @return void
  * @author Greg Froese
  **/
 public static function build_default_component_routes()
 {
     $components = SilkComponentManager::list_components();
     foreach ($components as $component => $controllers) {
         foreach ($controllers as $one_controller) {
             $class_name = str_replace("class.", "", str_replace(".php", "", str_replace("_controller", "", $one_controller)));
             if (count($controllers) > 1) {
                 $route = "/{$component}/{$class_name}/:action";
                 $params = array("component" => $component, "controller" => $class_name);
             } elseif (count($controllers) == 1 && $component == $class_name) {
                 $route = "/{$component}/:action";
                 $params = array("component" => $component, "controller" => $class_name);
             }
             SilkRoute::register_route($route, $params);
         }
     }
 }