<?php
$result = $this->flashMessenger()->load();
if (!$result) {
    return;
}
$class = function ($namespace) {
    $pattern = 'alert alert-dismissable alert-%s';
    switch ($namespace) {
        case 'success':
            $type = 'success';
            break;
        case 'error':
            $type = 'danger';
            break;
        case 'warning':
            $type = 'warning';
            break;
        case 'info':
        case 'default':
        default:
            $type = 'info';
            break;
    }
    return sprintf($pattern, $type);
};
foreach ($result as $namespace => $messages) {
    ?>
    <div class="<?php echo $class($namespace); ?>">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <?php foreach ($messages as $msg) { ?>
            <div><?php echo $msg; ?></div>
        <?php } ?>
    </div>
<?php } ?>