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

to calculate the project activities.
This commit is contained in:
Thomas Keller 2012-04-24 20:37:23 +02:00
parent bca3eb332e
commit e8882292b5

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');
} }