2017 © Pedro Peláez
 

library notices

Notices for Zend Framework 2/3

image

ilyaserdyuk/notices

Notices for Zend Framework 2/3

  • Monday, July 24, 2017
  • by IlyaSerdyuk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Notices for Zend Framework 2/3

Extension for displaying messages in Zend Framework 2/3 and Twitter bootstrap 3 applications., (*1)

Installation

Use Composer:, (*2)

$ composer require ilyaserdyuk/notices:^1.0

And add to layout:, (*3)

<?= $this->notices() ?>

How use

Send messages from the controllers:, (*4)

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $this->notices()->addSuccessMessage('You successfully read this important alert message.');
        $this->notices()->addInfoMessage('This alert needs your attention, but it\'s not super important.');
        $this->notices()->addWarningMessage('Better check yourself, you\'re not looking too good.');
        $this->notices()->addErrorMessage('Change a few things up and try submitting again.');
    }
}

Output:, (*5)



How to configure

You can customize the output template, turn off escaping and change the label of messages. To do this, add to config file (config/autoload/global.php):, (*6)

return [
    'view_helper_config' => [
        'notices' => [
            'auto_escape' => true,
            'template_string' => '<div class="alert alert-{class} alert-dismissible" role="alert">{text}</div>',
            'label_for_status' => [
                Message::CLASS_SUCCESS => 'Успешно:',
                Message::CLASS_INFO => 'Информация:',
                Message::CLASS_WARNING => 'Предупреждение:',
                Message::CLASS_ERROR => 'Ошибка:',
            ],
        ],
    ],
];

The Versions