classes/Route.php
public static function group($prefix, $callback){

      // Skip definition if current request doesn't match group.
      $pre_prefix = rtrim(implode('',static::$prefix),'/');
      $URI   = Request::URI();
      $args  = [];
      $group = false;

      switch (true) {

        // Dynamic group
        case static::isDynamic($prefix) :
          $args = static::extractVariablesFromURL($prx=static::compilePatternAsRegex("$pre_prefix$prefix"), null, true);
          if ( $args !== false ) {
            // Burn-in $prefix as static string
            $partial = preg_match_all(str_replace('$#', '#', $prx), $URI, $partial) ? $partial[0][0] : '';
            $prefix = $partial ? preg_replace('#^'.implode('',static::$prefix).'#', '', $partial) : $prefix;
          }

        // Static group
        case ( 0 === strpos("$URI/", "$pre_prefix$prefix/") )
             || ( ! Options::get('core.route.pruning', true) ) :

          static::$prefix[] = $prefix;
          if (empty(static::$group)) static::$group = [];
          array_unshift(static::$group, $group = new RouteGroup());

          // Call the group body function
          call_user_func_array($callback, $args ?: []);

          array_shift(static::$group);
          array_pop(static::$prefix);
          if (empty(static::$prefix)) static::$prefix = [''];
        break;

      }

      return $group ?: new RouteGroup();
    }
public static function group($prefix, $callback){

      // Skip definition if current request doesn't match group.
      $pre_prefix = rtrim(implode('',static::$prefix),'/');
      $URI   = Request::URI();
      $args  = [];
      $group = false;

      switch (true) {

        // Dynamic group
        case static::isDynamic($prefix) :
          $args = static::extractVariablesFromURL($prx=static::compilePatternAsRegex("$pre_prefix$prefix"), null, true);
          if ( $args !== false ) {
            // Burn-in $prefix as static string
            $partial = preg_match_all(str_replace('$#', '#', $prx), $URI, $partial) ? $partial[0][0] : '';
            $prefix = $partial ? preg_replace('#^'.implode('',static::$prefix).'#', '', $partial) : $prefix;
          }

        // Static group
        case ( 0 === strpos("$URI/", "$pre_prefix$prefix/") )
             || ( ! Options::get('core.route.pruning', true) ) :

          static::$prefix[] = $prefix;
          if (empty(static::$group)) static::$group = [];
          array_unshift(static::$group, $group = new RouteGroup());

          // Call the group body function
          call_user_func_array($callback, $args ?: []);

          array_shift(static::$group);
          array_pop(static::$prefix);
          if (empty(static::$prefix)) static::$prefix = [''];
        break;

      }

      return $group ?: new RouteGroup();
    }
public static function group ( $ prefix , $ callback ) { // Skip definition if current request doesn't match group. $ pre_prefix = rtrim ( implode ( '' , static :: $ prefix ) , '/' ) ; $ URI = Request :: URI ( ) ; $ args = [ ] ; $ group = false ; switch ( true ) { // Dynamic group case static :: isDynamic ( $ prefix ) : $ args = static :: extractVariablesFromURL ( $ prx = static :: compilePatternAsRegex ( "$pre_prefix$prefix" ) , null , true ) ; if ( $ args !== false ) { // Burn-in $prefix as static string $ partial = preg_match_all ( str_replace ( '$#' , '#' , $ prx ) , $ URI , $ partial ) ? $ partial [ 0 ] [ 0 ] : '' ; $ prefix = $ partial ? preg_replace ( '#^' . implode ( '' , static :: $ prefix ) . '#' , '' , $ partial ) : $ prefix ; } // Static group case ( 0 === strpos ( "$URI/" , "$pre_prefix$prefix/" ) ) || ( ! Options :: get ( 'core.route.pruning' , true ) ) : static :: $ prefix [ ] = $ prefix ; if ( empty ( static :: $ group ) ) static :: $ group = [ ] ; array_unshift ( static :: $ group , $ group = new RouteGroup ( ) ) ; // Call the group body function call_user_func_array ( $ callback , $ args ? : [ ] ) ; array_shift ( static :: $ group ) ; array_pop ( static :: $ prefix ) ; if ( empty ( static :: $ prefix ) ) static :: $ prefix = [ '' ] ; break ; } return $ group ? : new RouteGroup ( ) ; }
Define a route group, if not immediately matched internal code will not be invoked.
@param  string $prefix The url prefix for the internal route definitions.
@param  string $callback This callback is invoked on $prefix match of the current request URI.
Define a route group if not immediately matched internal code will not be invoked .