From 12d1a7e8919ce69b1258b2c23c2743176b2f86ac Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 31 Mar 2014 23:47:00 -0400 Subject: [PATCH] Move setup logic into FrontController::__construct(). --- admin/index.php | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/admin/index.php b/admin/index.php index dda4edc..8a69dc0 100644 --- a/admin/index.php +++ b/admin/index.php @@ -45,6 +45,32 @@ class FrontController implements http\RootControllerDelegate public function __construct(http\RootController $controller) { $this->controller = $controller; + + $url_map = new http\UrlMap($controller); + $url_map->set_file_loader(function($name, $value) { + require_once BUGDAR_ROOT . '/admin/' . $value; + return 'bugdar\\admin\\' . $name . 'Action'; + }); + $controller->set_url_map($url_map); + + $url_map->set_map(array( + '' => 'home', + 'fields/{action}' => 'fields', + 'settings' => 'settings', + )); + + $output_filter = new http\OutputFilter($controller); + $controller->set_output_filter($output_filter); + + $tpl_loader = views\TemplateLoader::GetInstance(); + $tpl_loader->set_template_path(BUGDAR_ROOT . '/admin/templates/%s.tpl'); + $tpl_loader->set_cache_backend(new views\PDOCacheBackend( + Bugdar::$db, // PDO object. + TABLE_PREFIX . 'template', // Database table. + 'filename', // Name column. + 'template', // Data column. + 'timestamp' // Modified time column. + )); } public function LoginPage() @@ -103,35 +129,9 @@ interface TemplatePreCaching public function TemplateSet(); } -$controller = new http\RootController($GLOBALS); -$controller->set_delegate(new FrontController($controller)); - -$url_map = new http\UrlMap($controller); -$url_map->set_file_loader(function($name, $value) { - require_once BUGDAR_ROOT . '/admin/' . $value; - return 'bugdar\\admin\\' . $name . 'Action'; -}); -$controller->set_url_map($url_map); - -$url_map->set_map(array( - '' => 'home', - 'fields/{action}' => 'fields', - 'settings' => 'settings', -)); - -$output_filter = new http\OutputFilter($controller); -$controller->set_output_filter($output_filter); - -$tpl_loader = views\TemplateLoader::GetInstance(); -$tpl_loader->set_template_path(BUGDAR_ROOT . '/admin/templates/%s.tpl'); -$tpl_loader->set_cache_backend(new views\PDOCacheBackend( - Bugdar::$db, // PDO object. - TABLE_PREFIX . 'template', // Database table. - 'filename', // Name column. - 'template', // Data column. - 'timestamp' // Modified time column. -)); - error_reporting(E_ALL); +$controller = new http\RootController($GLOBALS); +$delegate = new FrontController($controller); +$controller->set_delegate($delegate); $controller->Run(); -- 2.43.5