Move project overriding into a function on the shared project list base
Move project overriding into a function on the shared project list base

--- a/include/git/ProjectListArray.class.php
+++ b/include/git/ProjectListArray.class.php
@@ -57,22 +57,8 @@
 				if (isset($projData['project'])) {
 					try {
 						$projObj = new GitPHP_Project($projData['project']);
-						if (isset($projData['category']) && is_string($projData['category'])) {
-							$projObj->SetCategory($projData['category']);
-						}
-						if (isset($projData['owner']) && is_string($projData['owner'])) {
-							$projObj->SetOwner($projData['owner']);
-						}
-						if (isset($projData['description']) && is_string($projData['description'])) {
-							$projObj->SetDescription($projData['description']);
-						}
-						if (isset($projData['cloneurl']) && is_string($projData['cloneurl'])) {
-							$projObj->SetCloneUrl($projData['cloneurl']);
-						}
-						if (isset($projData['pushurl']) && is_string($projData['pushurl'])) {
-							$projObj->SetPushUrl($projData['pushurl']);
-						}
 						$this->projects[$projData['project']] = $projObj;
+						$this->ApplyProjectOverride($projData);
 					} catch (Exception $e) {
 					}
 				}

--- a/include/git/ProjectListBase.class.php
+++ b/include/git/ProjectListBase.class.php
@@ -204,5 +204,40 @@
 		return count($this->projects);
 	}
 
+	/**
+	 * ApplyProjectOverride
+	 *
+	 * Applies override settings for a project
+	 *
+	 * @access protected
+	 * @param array $projData project data array
+	 */
+	protected function ApplyProjectOverride($projData)
+	{
+		if ((!isset($projData['project'])) || empty($projData['project']))
+			return;
+
+		$project = $this->GetProject($projData['project']);
+		if (!$project)
+			return;
+
+
+		if (isset($projData['category']) && is_string($projData['category'])) {
+			$project->SetCategory($projData['category']);
+		}
+		if (isset($projData['owner']) && is_string($projData['owner'])) {
+			$project->SetOwner($projData['owner']);
+		}
+		if (isset($projData['description']) && is_string($projData['description'])) {
+			$project->SetDescription($projData['description']);
+		}
+		if (isset($projData['cloneurl']) && is_string($projData['cloneurl'])) {
+			$project->SetCloneUrl($projData['cloneurl']);
+		}
+		if (isset($projData['pushurl']) && is_string($projData['pushurl'])) {
+			$project->SetPushUrl($projData['pushurl']);
+		}
+	}
+
 }
 

comments