Get rid of config singleton
Get rid of config singleton

--- a/include/Config.class.php
+++ b/include/Config.class.php
@@ -28,14 +28,6 @@
  */
 class GitPHP_Config
 {
-	
-	/**
-	 * Stores the singleton instance
-	 *
-	 * @var GitPHP_Config
-	 */
-	protected static $instance;
-
 	/**
 	 * Stores the config values
 	 *
@@ -58,30 +50,9 @@
 	protected $configs = array();
 
 	/**
-	 * Returns the singleton instance
-	 *
-	 * @return GitPHP_Config instance of config class
-	 */
-	public static function GetInstance()
-	{
-		if (!self::$instance) {
-			self::$instance = new GitPHP_Config();
-		}
-		return self::$instance;
-	}
-
-	/**
-	 * Releases the singleton instance
-	 */
-	public static function DestroyInstance()
-	{
-		self::$instance = null;
-	}
-
-	/**
 	 * Class constructor
 	 */
-	private function __construct()
+	public function __construct()
 	{
 		$this->InitializeDefaults();
 	}

--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -92,7 +92,7 @@
 	 */
 	public function __construct()
 	{
-		$this->config = GitPHP_Config::GetInstance();
+		$this->InitializeConfig();
 
 		$this->InitializeResource();
 
@@ -126,6 +126,15 @@
 			$this->params['searchtype'] = $_GET['st'];
 
 		$this->ReadQuery();
+	}
+
+	/**
+	 * Initialize config
+	 */
+	protected function InitializeConfig()
+	{
+		$this->config = new GitPHP_Config();
+		$this->config->LoadConfig(GITPHP_CONFIGDIR . 'gitphp.conf.php');
 	}
 
 	/**

--- a/include/controller/Controller_Message.class.php
+++ b/include/controller/Controller_Message.class.php
@@ -14,7 +14,7 @@
 	 */
 	public function __construct()
 	{
-		$this->config = GitPHP_Config::GetInstance();
+		$this->InitializeConfig();
 
 		$this->InitializeResource();
 

--- a/include/controller/Controller_Snapshot.class.php
+++ b/include/controller/Controller_Snapshot.class.php
@@ -22,7 +22,7 @@
 	 */
 	public function __construct()
 	{
-		$this->config = GitPHP_Config::GetInstance();
+		$this->InitializeConfig();
 
 		$this->InitializeGitExe();
 

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -44,11 +44,6 @@
 
 try {
 
-	/*
-	 * Configuration
-	 */
-	GitPHP_Config::GetInstance()->LoadConfig(GITPHP_CONFIGDIR . 'gitphp.conf.php');
-
 	$controller = GitPHP_Controller::GetController((isset($_GET['a']) ? $_GET['a'] : null));
 	if ($controller) {
 		$controller->RenderHeaders();
@@ -72,8 +67,6 @@
 
 }
 
-GitPHP_Config::DestroyInstance();
-
 if (isset($controller)) {
 	$log = $controller->GetLog();
 	if ($log && $log->GetEnabled()) {

comments