classes/Route.php
public static function add($route){
      if (is_a($route, 'Route')){

        // Add to tag map
        if ($route->tag) static::$tags[$route->tag] =& $route;

        // Optimize tree
        if (Options::get('core.route.auto_optimize', true)){
          $base =& static::$optimized_tree;
          foreach (explode('/',trim(preg_replace('#^(.+?)\(?:.+$#','$1',$route->URLPattern),'/')) as $segment) {
            $segment = trim($segment,'(');
            if (!isset($base[$segment])) $base[$segment] = [];
            $base =& $base[$segment];
          }
          $base[] =& $route;
        }
      }

      // Add route to active group
      if ( isset(static::$group[0]) ) static::$group[0]->add($route);

      return static::$routes[implode('', static::$prefix)][] = $route;
    }
public static function add($route){
      if (is_a($route, 'Route')){

        // Add to tag map
        if ($route->tag) static::$tags[$route->tag] =& $route;

        // Optimize tree
        if (Options::get('core.route.auto_optimize', true)){
          $base =& static::$optimized_tree;
          foreach (explode('/',trim(preg_replace('#^(.+?)\(?:.+$#','$1',$route->URLPattern),'/')) as $segment) {
            $segment = trim($segment,'(');
            if (!isset($base[$segment])) $base[$segment] = [];
            $base =& $base[$segment];
          }
          $base[] =& $route;
        }
      }

      // Add route to active group
      if ( isset(static::$group[0]) ) static::$group[0]->add($route);

      return static::$routes[implode('', static::$prefix)][] = $route;
    }
public static function add ( $ route ) { if ( is_a ( $ route , 'Route' ) ) { // Add to tag map if ( $ route -> tag ) static :: $ tags [ $ route -> tag ] = & $ route ; // Optimize tree if ( Options :: get ( 'core.route.auto_optimize' , true ) ) { $ base = & static :: $ optimized_tree ; foreach ( explode ( '/' , trim ( preg_replace ( '#^(.+?)\(?:.+$#' , '$1' , $ route -> URLPattern ) , '/' ) ) as $ segment ) { $ segment = trim ( $ segment , '(' ) ; if ( ! isset ( $ base [ $ segment ] ) ) $ base [ $ segment ] = [ ] ; $ base = & $ base [ $ segment ] ; } $ base [ ] = & $ route ; } } // Add route to active group if ( isset ( static :: $ group [ 0 ] ) ) static :: $ group [ 0 ] -> add ( $ route ) ; return static :: $ routes [ implode ( '' , static :: $ prefix ) ] [ ] = $ route ; }
Add a route to the internal route repository.
@param Route $route
@return Route
Add a route to the internal route repository .