Try to move config out of singleton implementations
--- a/include/Log.class.php
+++ b/include/Log.class.php
@@ -83,7 +83,8 @@
public static function GetInstance()
{
if (!self::$instance) {
- self::$instance = new GitPHP_Log();
+ $config = GitPHP_Config::GetInstance();
+ self::$instance = new GitPHP_Log($config->GetValue('debug', false), $config->GetValue('benchmark', false));
}
return self::$instance;
@@ -110,13 +111,13 @@
* @access private
* @return Log object
*/
- private function __construct()
+ private function __construct($enabled = false, $benchmark = false)
{
$this->startTime = microtime(true);
$this->startMem = memory_get_usage();
- $this->enabled = GitPHP_Config::GetInstance()->GetValue('debug', false);
- $this->benchmark = GitPHP_Config::GetInstance()->GetValue('benchmark', false);
+ $this->enabled = $enabled;
+ $this->benchmark = $benchmark;
}
/**
--- a/include/git/GitExe.class.php
+++ b/include/git/GitExe.class.php
@@ -84,7 +84,7 @@
public static function GetInstance()
{
if (!self::$instance) {
- self::$instance = new GitPHP_GitExe();
+ self::$instance = new GitPHP_GitExe(GitPHP_Config::GetInstance()->GetValue('gitbin'));
}
return self::$instance;
}
@@ -111,9 +111,8 @@
* @param string $binary path to git binary
* @return mixed git executable class
*/
- protected function __construct()
- {
- $binary = GitPHP_Config::GetInstance()->GetValue('gitbin');
+ protected function __construct($binary)
+ {
if (empty($binary)) {
$binary = GitPHP_GitExe::DefaultBinary();
}