/** * Boilerplate Singleton method * * @return object Starch_Router * * @access public */ public static function getInstance() { if (!isset(self::$_instance)) { $object = __CLASS__; self::$_instance = new $object(); } return self::$_instance; }
/** * Runs framework * * @param object $config Starch_Conifg * @return void * @access public */ public function run(Starch_Config $config) { //Set config for class self::setConfig($config); //Create router object $router = Starch_Router::getInstance(); $router->addRoutesFromConfig($config); //Load request $request = new Starch_Request(); //Send request to dispatch $dispatch = new Starch_Dispatcher($request); }
function testSmoke() { //Load project config //TODO: Change to test config (?) $config = new Example_Config(); //Check Starch and Request $this->assertTrue(new Starch()); $this->assertTrue(new Starch_Request()); //Check set config staic call Starch::setConfig($config); $this->assertEqual(Starch::getConfig(), $config); //Start the router instance $this->assertTrue(Starch_Router::getInstance()); //Check Route class $url_array = array('/', '/system/test/test_app.php', 'test_app', 'test_method', ''); $this->assertTrue(new Starch_Route($url_array)); }
/** * Finds route matching URI. * * @param string $uri * @return object|null Starch_Route * * @access public */ public function findRoute($uri) { $router = Starch_Router::getInstance(); $route = $router->route($uri); return $route; }