Improve the error we throw at the user if no configuration is found

to calculate the project activities.
release-1.3
Thomas Keller 2012-04-24 20:37:23 +02:00
parent bca3eb332e
commit e8882292b5
1 changed files with 6 additions and 2 deletions

View File

@ -44,10 +44,15 @@ class IDF_ActivityTaxonomy
{ {
public static function recalculateTaxnomies(DateTime $date) 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 // query and normalize the section weights
// //
$sectionWeights = Pluf::f('activity_section_weights', array());
$allWeights = array_sum($sectionWeights); $allWeights = array_sum($sectionWeights);
if ($allWeights == 0) { if ($allWeights == 0) {
throw new LogicException('the sum of all "activity_section_weights" must not be 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 // determine the date boundaries
// //
$lookback = Pluf::f('activity_lookback', 0);
if ($lookback < 1) { if ($lookback < 1) {
throw new LogicException('lookback must be greater or equal to 1'); throw new LogicException('lookback must be greater or equal to 1');
} }