class RequestHandler {
protected $pattern = "";
protected $routeData = array();
- protected $controllers = array();
/**
* init RequestHandler
*/
public function __construct ($module = '') {
$this->pattern = '~/?(?:(?P<controller>[A-Za-z0-9\-]+)(?:/(?P<id>\d+)(?:-(?P<title>[^/]+))?)?)?~x';
- $this->getControllers($module);
+ $controllers = ControllerCacheBuilder::getInstance()->getData(array('module' => $module));
if (DNS::getSession()->username !== null) {
DNS::getTPL()->assign(array("username" => DNS::getSession()->username));
if (isset($this->routeData['controller']) && !empty($this->routeData['controller'])) {
$controller = strtolower($this->routeData['controller']);
- if (isset($this->controllers[$controller]) && !empty($this->controllers[$controller])) {
- $className = $this->controllers[$controller];
+ if (isset($controllers[$controller]) && !empty($controllers[$controller])) {
+ $className = $controllers[$controller];
}
else {
@header('HTTP/1.0 404 Not Found');
}
}
- public function getControllers ($module) {
-
- $this->controllers = ControllerCacheBuilder::getInstance()->getData(array('module' => $module));
- /*
- $pages = glob(DNS_DIR.'/lib/'.(empty($module) ? '' : $module.'/').'page/*Page.class.php');
-
- foreach ($pages as $page) {
- $page = str_replace('Page.class.php', '', basename($page));
-
- $class = "\\dns".(empty($module) ? '' : "\\".$module)."\\page\\".$page."Page";
- if (class_exists($class) && is_subclass_of($class, '\\dns\\page\\AbstractPage')) {
- $this->controllers[strtolower($page)] = $class;
- }
- }
- */
- }
-
public function matches($requestURL) {
if (preg_match($this->pattern, $requestURL, $matches)) {
foreach ($matches as $key => $value) {