fix error when topinterval is not defined

This commit is contained in:
Nicolas Debrigode 2018-01-17 09:52:29 +01:00
parent 52e4ea172b
commit 8db3267904
3 changed files with 26 additions and 15 deletions

View File

@ -5,6 +5,8 @@
"twig/extensions": "~1.5",
"symfony/twig-bridge": "^3.3",
"symfony/yaml": "^3.3",
"symfony/translation": "^3.3",
"symfony/config": "^3.3",
"ddesrosiers/silex-annotation-provider": "~2.0",
"doctrine/dbal": "~2.5",
"mobiledetect/mobiledetectlib": "^2.8",

View File

@ -17,10 +17,12 @@ class DbsProvider
}
$dbs = ConfigApplication::getTopInterval();
foreach ($dbs as $key => $val)
{
$db[$key."statsfile"]['path'] = $val['statsfile'];
$db[$key."statsfile"]['driver'] = 'pdo_sqlite';
if ( $dbs ) {
foreach ($dbs as $key => $val)
{
$db[$key."statsfile"]['path'] = $val['statsfile'];
$db[$key."statsfile"]['driver'] = 'pdo_sqlite';
}
}
return $db;

View File

@ -150,21 +150,28 @@ class Func
public function statsFileForHours($hours)
{
foreach (ConfigApplication::getTopInterval() as $key => $interval) {
if ($interval['hours'] == $hours) {
return $key."statsfile";
}
}
$top = ConfigApplication::getTopInterval();
if ( $top ) {
foreach ($top as $key => $interval) {
if ($interval['hours'] == $hours) {
return $key."statsfile";
}
}
}
return "daystatsfile";
}
public function statsLabelForHours($hours)
{
foreach (ConfigApplication::getTopInterval() as $key => $interval) {
if ($interval['hours'] == $hours) {
return $interval['label'];
}
}
return (int)$hours . " hours";
$top = ConfigApplication::getTopInterval();
if ( $top ) {
foreach ($top as $key => $interval) {
if ($interval['hours'] == $hours) {
return $interval['label'];
}
}
}
return (int)$hours . " hours";
}
}