public function testGetTrace() { $instance = new CallStack(); $actual = $instance->getTrace(); try { throw new \Exception(); } catch (\Exception $e) { $expected = $e->getTrace(); } $this->assertEquals(array_slice($expected, 1), array_slice($actual, 2)); }
function call($controller_name, $action_and_format, $params = null) { $tokens = explode(".", $action_and_format); $token_count = count($tokens); switch ($token_count) { case 1: return CallStack::call($controller_name, $tokens[0], "rawp", $params); case 2: return CallStack::call($controller_name, $tokens[0], $tokens[1], $params); default: throw new InvalidParameterException("Nome della action non valido!! : " . $action_and_format); } }
public static function dispatch() { $route_matched = false; $request_uri = Engines::getRequestUri(); foreach (self::$route_definitions as $def) { if ($def->matches($request_uri)) { $route_matched = true; $match = $def->getMatch($request_uri); $controller_name = $match->getController(); $action_name = $match->getAction(); $format_name = $match->getFormat(); CallStack::call($controller_name, $action_name, $format_name, array()); } } if (!$route_matched) { foreach (self::$route_definitions as $route_def) { echo $route_def->dump(); } Log::error("dispatch", "Mapping not found for URL : " . Engines::getRequestUri()); } }
function is_xml() { return CallStack::peek()->get_format() == "xml"; }