public function testExecuteRoute()
 {
     $Router = new Router(array());
     $route = $Router->parseRoute();
     $Router->executeRoute($route);
     $this->assertEquals($Router->controller->calledAction, 'util');
     $this->assertEquals($Router->controller->actionParams, array('router'));
 }
Example #2
0
 /**
  * Starts the PhpBURN Application - Should be called at the index of the application
  * <code>
  * PhpBURN::StartApplication();
  * </code>
  */
 public static function startApplication()
 {
     self::enableAutoload();
     //              Setting up Controller
     if (array_search('Controller', get_declared_classes()) == true) {
         PhpBURN::load('Tools.Util.Router');
         include_once SYS_APPLICATION_PATH . DS . 'config' . DS . 'routes.php';
         //Define the main route functions
         $router = new Router($routes);
         $currentRoute = $router->parseRoute();
         if ($currentRoute != false) {
             $router->executeRoute($currentRoute);
         } else {
             @Controller::callErrorPage('404');
         }
     }
 }
Example #3
0
 /**
  * Starts the PhpBURN Application - Should be called at the index of the application
  * <code>
  * PhpBURN::StartApplication();
  * </code>
  */
 public static function startApplication()
 {
     //              Setting up Model
     if (array_search('PhpBURN_Core', get_declared_classes()) == true) {
         //                  Adds Models Paths to include Path
         $packages = PhpBURN_Configuration::getConfig();
         foreach ($packages as $package => $configItem) {
             $includePath = get_include_path();
             $separator = strpos($includePath, ':') !== false ? ':' : ';';
             set_include_path($includePath . $separator . $configItem->class_path . DS . $package);
         }
     }
     //              Setting up Controller
     if (array_search('Controller', get_declared_classes()) == true) {
         PhpBURN::load('Tools.Util.Router');
         include_once SYS_APPLICATION_PATH . DS . 'config' . DS . 'routes.php';
         //Define the main route functions
         $router = new Router($routes);
         $currentRoute = $router->parseRoute();
         if ($currentRoute != false) {
             $router->executeRoute($currentRoute);
         } else {
             Controller::callErrorPage('404');
         }
     }
 }
Example #4
0
 /**
  * Parse the given route and return the name of a controller mapped to the given route.
  *
  * @param   string  $route  The route string for which to find and execute a controller.
  *
  * @return  string  The controller name for the given route excluding prefix.
  *
  * @since   1.0
  * @throws  \InvalidArgumentException
  */
 protected function parseRoute($route)
 {
     $name = parent::parseRoute($route);
     // Append the HTTP method based suffix.
     $name .= $this->fetchControllerSuffix();
     return $name;
 }