From 2b93fe0c9417a630edbb84176b9566275c5342ea Mon Sep 17 00:00:00 2001 From: meadsteve Date: Tue, 25 Feb 2014 22:36:20 +0000 Subject: [PATCH] add getProjectTitle convenience method to the Build class. --- PHPCI/Helper/BuildInterpolator.php | 2 +- PHPCI/Model/Build.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/PHPCI/Helper/BuildInterpolator.php b/PHPCI/Helper/BuildInterpolator.php index 4732607c..d4609793 100644 --- a/PHPCI/Helper/BuildInterpolator.php +++ b/PHPCI/Helper/BuildInterpolator.php @@ -27,7 +27,7 @@ class BuildInterpolator $this->interpolation_vars['%COMMIT%'] = $build->getCommitId(); $this->interpolation_vars['%PROJECT%'] = $build->getProjectId(); $this->interpolation_vars['%BUILD%'] = $build->getId(); - $this->interpolation_vars['%PROJECT_TITLE%'] = $build->getProject()->getTitle(); + $this->interpolation_vars['%PROJECT_TITLE%'] = $build->getProjectTitle(); $this->interpolation_vars['%BUILD_PATH%'] = $buildPath; $this->interpolation_vars['%BUILD_URI%'] = $phpCiUrl . "build/view/" . $build->getId(); $this->interpolation_vars['%PHPCI_COMMIT%'] = $this->interpolation_vars['%COMMIT%']; diff --git a/PHPCI/Model/Build.php b/PHPCI/Model/Build.php index f17fcc74..ff0a0b23 100644 --- a/PHPCI/Model/Build.php +++ b/PHPCI/Model/Build.php @@ -36,6 +36,15 @@ class Build extends BuildBase return '#'; } + /** + * @return string + */ + public function getProjectTitle() + { + $project = $this->getProject(); + return $project ? $project->getTitle() : ""; + } + /** * Get link to branch from another source (i.e. Github) */