From e8882292b5f085e5bab6f307a627360fbdcfe2cb Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Tue, 24 Apr 2012 20:37:23 +0200 Subject: [PATCH] Improve the error we throw at the user if no configuration is found to calculate the project activities. --- src/IDF/ActivityTaxonomy.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/IDF/ActivityTaxonomy.php b/src/IDF/ActivityTaxonomy.php index 1d99046..7b24370 100644 --- a/src/IDF/ActivityTaxonomy.php +++ b/src/IDF/ActivityTaxonomy.php @@ -44,10 +44,15 @@ class IDF_ActivityTaxonomy { public static function recalculateTaxnomies(DateTime $date) { + $sectionWeights = Pluf::f('activity_section_weights', null); + $lookback = Pluf::f('activity_lookback', null); + if ($sectionWeights === null || $lookback === null) { + throw new LogicException('activity configuration is missing in idf.php'); + } + // // query and normalize the section weights // - $sectionWeights = Pluf::f('activity_section_weights', array()); $allWeights = array_sum($sectionWeights); if ($allWeights == 0) { throw new LogicException('the sum of all "activity_section_weights" must not be 0'); @@ -59,7 +64,6 @@ class IDF_ActivityTaxonomy // // determine the date boundaries // - $lookback = Pluf::f('activity_lookback', 0); if ($lookback < 1) { throw new LogicException('lookback must be greater or equal to 1'); }