mb-tec/zf-super-messenger

This package is abandoned and no longer maintained. No replacement package was suggested.

ZF3 module v1.1 - Boost your FlashMessenger !

1.1 2016-10-23 17:59 UTC

This package is not auto-updated.

Last update: 2023-03-19 11:12:41 UTC


README

Version 1.1 Created by Matthias Büsing

/!\ This module is now a PR to Zend Framework 3 : zendframework/zendframework#3502. Give me your feedback !

Introduction

ZF3 SuperMessenger module provide new features for plugin FlashMessenger. Now, you can add directly 3 level of messages : success message, error message or info message.

Usage

• Usage in controller :

$this->flashMessenger()->addInfoMessage('bar-info');
$this->flashMessenger()->addSuccessMessage('bar-success');
$this->flashMessenger()->addErrorMessage('bar-error');

Just active the module and the FlashMessenger will have features without BC ! You can use SuperMessenger by the identifier "FlashMessenger" with the alias. You could use the identifier "SuperMessenger" to pilot the plugin.

• Usage in view :

And to be complete, there is a view helper. Usage in a view to get list of messages :

<?php
    $infoMessages = $this->flashMessenger('info');
?>

You can directly have a render of the messages :

<?php
    echo $this->flashMessenger()->render('info');
?>

By default, the format is :

<ul class="info">
    <li>first message</li>
    <li>second message</li>
</ul>

You can change the format, like this :

<?php
    echo $this->flashMessenger()
                ->setMessageOpenFormat('<div%s><p>')
                ->setMessageSeparatorString('</p><p>')
                ->setMessageCloseString('</p></div>')
                ->render('info');
?>

Format could be changed in supermessenger.local.php which will be moved in "/config/autoload" :

'view_helper' => array(
    'supermessenger' => array(
        'message_open_format' => '<div%s><ul><li>',
        'message_separator_string' => '</li><li>',
        'message_close_string' => '</li></ul></div>',
    ),
),

You can change easily the class CSS with :

<?php
    echo $this->flashMessenger()->render('info', array('foo-baz', 'foo-bar'));
?>
<ul class="foo-baz foo-bar">
    <li>first message</li>
    <li>second message</li>
</ul>