Skip to content

Commit

Permalink
check if flashmessages are available before passing them to foreach
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte Heyenga committed Mar 25, 2019
1 parent e73dbc8 commit bcce821
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Resources/contao/modules/ModuleFlashMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ protected function compile() {
$flashMessages = Flash::load();

$ids = [];
$encIds = [];
foreach($flashMessages as $flash){
if(!$flash->autoDismiss) continue;
$ids[] = $flash->id;
$encIds[] = "\"$flash->id\"";
}
$encIds = [];

if($flashMessages) {
foreach($flashMessages as $flash){
if(!$flash->autoDismiss) continue;
$ids[] = $flash->id;
$encIds[] = "\"$flash->id\"";
}
}

$this->Template->flashMessages = $flashMessages;
$this->Template->ids = $ids;
$this->Template->encIds = $encIds;
Expand Down

0 comments on commit bcce821

Please sign in to comment.