Example #1
0
 /**
  * Instantiates the project list
  *
  * @param GitPHP_Config $config config provider
  * @param string $file config file with git projects
  * @param boolean $legacy true if this is the legacy project config
  * @throws Exception if there was an error reading the file
  */
 public static function Instantiate($config, $file = null, $legacy = false)
 {
     $instance = null;
     $projectRoot = $config->GetValue('projectroot');
     if (!empty($file) && is_file($file) && (include $file)) {
         if (isset($git_projects)) {
             if (is_string($git_projects)) {
                 if (function_exists('simplexml_load_file') && GitPHP_ProjectListScmManager::IsSCMManager($git_projects)) {
                     $instance = new GitPHP_ProjectListScmManager($projectRoot, $git_projects);
                 } else {
                     $instance = new GitPHP_ProjectListFile($projectRoot, $git_projects);
                 }
             } else {
                 if (is_array($git_projects)) {
                     if ($legacy) {
                         $instance = new GitPHP_ProjectListArrayLegacy($projectRoot, $git_projects);
                     } else {
                         $instance = new GitPHP_ProjectListArray($projectRoot, $git_projects);
                     }
                 }
             }
         }
     }
     if (!$instance) {
         $instance = new GitPHP_ProjectListDirectory($projectRoot, $config->GetValue('exportedonly'));
     }
     $instance->SetConfig($config);
     if (isset($git_projects_settings) && !$legacy) {
         $instance->SetProjectSettings($git_projects_settings);
     }
     return $instance;
 }
Example #2
0
 /**
  * Instantiate
  *
  * Instantiates the singleton instance
  *
  * @access private
  * @static
  * @param string $file config file with git projects
  * @param boolean $legacy true if this is the legacy project config
  * @throws Exception if there was an error reading the file
  */
 public static function Instantiate($file = null, $legacy = false)
 {
     if (self::$instance) {
         return;
     }
     if (!empty($file) && is_file($file) && (include $file)) {
         if (isset($git_projects)) {
             if (is_string($git_projects)) {
                 if (function_exists('simplexml_load_file') && GitPHP_ProjectListScmManager::IsSCMManager($git_projects)) {
                     self::$instance = new GitPHP_ProjectListScmManager($git_projects);
                 } else {
                     self::$instance = new GitPHP_ProjectListFile($git_projects);
                 }
             } else {
                 if (is_array($git_projects)) {
                     if ($legacy) {
                         self::$instance = new GitPHP_ProjectListArrayLegacy($git_projects);
                     } else {
                         self::$instance = new GitPHP_ProjectListArray($git_projects);
                     }
                 }
             }
         }
     }
     if (!self::$instance) {
         self::$instance = new GitPHP_ProjectListDirectory(GitPHP_Config::GetInstance()->GetValue('projectroot'));
     }
     if (isset($git_projects_settings) && !$legacy) {
         self::$instance->ApplySettings($git_projects_settings);
     }
 }