rocketmedia-cz/flashmessages

Visual component for displaying FlashMessages

1.0.1 2014-03-01 08:23 UTC

README

This simple visual addon help to display and translate flash messages.

Requirements

Installation

The best way is by Composer:

    $ composer require rocketmedia-cz/flashmessages:dev-master

Or you can simple download package and place it to vendor/others folder.

and you must enable addon through your cofing.neon, just put these lines into it

services:
    flashmessages:
        implement: Scribe\Addons\FlashMessages\IFlashMessagesControlFactory
        parameters: [templateFile, translator]
        arguments: [%templateFile%, %translator%]

or if you won't change template file or use translator with magic function throught interface, you can use shorted version

services:
    flashmessages: Scribe\Addons\FlashMessages\IFlashMessagesControlFactory

Setup

In presenter we can use @inject annotation from Nette version 2.1 -

/** @var \Scribe\Addons\FlashMessages\IFlashMessagesControlFactory @inject */
public $flashMessagesControl;

/**
 * @return \Scribe\Addons\FlashMessages\FlashMessagesControl
 */
protected function createComponentFlashMessages()
{
    return $this->flashMessagesControl->create();
}

If we want to change template file or translate our messages, we have to change parameters in create() function.

return $this->flashMessagesControl->create('newTemplateFile.latte', $ourTranslator);

Usage

Just initialize component in template and it is.

{control flashMessages}

Default template is in snippet, so you can redraw snippet with flash messages

$this->redrawControl('flashMessages');

Created by David Zadražil for Rocketmedia.cz.