Hello,
I have the following problem with my script:
Fatal error: Call to a member function getModule() on a non-object in /Applications/MAMP/htdocs/framing10/library/Main/Dispatcher.php on line 22
This is a part of my code:
class Main_Dispatcher
{
public static function dispatch($router)
{
global $app;
ob_start();
$config = Main_Loader::loadClass("Main_Config");
if ($config->session_auto_start)
{
$session = Main_Loader::loadClass("Main_Session");
//if (isset($_REQUEST['PHPSESSID'])) {
//session_id($_REQUEST['PHPSESSID']);
//}
$session->start();
}
$char_encoding = $config->char_encoding;
if (empty($char_encoding)) $char_encoding="iso-8859-1";
header("Content-Type: text/html; charset={$char_encoding}");
if ($config->global_profile) $start = microtime(true);
$module = $router->getModule();
$controller = $router->getController();
$action = $router->getAction();
$params = $router->getParams();
if (count($params)>=1){
if ("Unittest"==$params[count($params)-1] || '1'==$_POST['Unittest'])
unittest::setUp();
}
This is a part of the Router
class Main_Router
{
private $route;
private $module;
private $controller;
private $action;
private $params;
public function __construct()
{
if(file_exists(APPLICATION_PATH ."/config/routes.php"))
{
include_once(APPLICATION_PATH . "/config/routes.php");
}
$path = (empty($_GET['rt'])) ? '' : $_GET['rt'];
$routParts = explode('/', $path);
$this->module = $routParts[0];
if(isset( $routParts[1]))
{
$this->controller = $routParts[1];
if(isset( $routParts[2]))
{
$this->action = $routParts[2];
}
}
if (empty($this->module))
{
$this->module = "default";
}
if (empty($this->controller))
{
$this->controller = "index";
}
if (empty($this->action))
{
$this->action = "index";
}
}
public function getAction()
{
return $this->action;
}
public function getController()
{
return $this->controller;
}
public function getModule()
{
return $this->module;
}
Anyone an idea what's going wrong?
Thanks in advance.