holabs / flashes
Flash messages extension for Nette Framework
1.0.1
2017-11-22 07:25 UTC
Requires
- php: >=5.6
- holabs/ui: ~1.0
- nette/application: ~2.4
- nette/http: ~2.4
- nette/utils: ~2.4
This package is auto-updated.
Last update: 2024-11-20 01:31:43 UTC
README
Installation
Require:
composer require holabs/flashes
Configuration
extensions: flashes: Holabs\Flashes\Bridges\Nette\FlashesExtension
Using
BasePresenter
class:
use Nette\Application\UI\Presenter; use Holabs\Flashes\Message; use Holabs\Flashes\UI\IFactory; use Holabs\Flashes\UI\Control; class BasePresenter extends Presenter { use TFlasher; // Inject flash factory /** @var IFactory @inject */ public $flashesControlFactory; // Optional public function actionDefault(){ $this->flashMessage('Hello world!', Message::$INFO); $this->flashMessage('Hello world with link!', Message::$INFO) ->setLink($this->link('link'), 'Nice link'); } // Optional component /** * @return Control */ protected function createComponentFlashes(){ $control = $this->flashesControlFactory->create($this); // $control->setTemplateFile('path/to/your/latte') return $control; } // ... }
@layout.latte
file:
{* ... *} {* Standard render *} <div n:foreach="$messages as $message" class="flash flash-{$message->getType()}"> {$message->getMessage()}. <a href="{$message->getLink()->url}" n:if="$message->getLink()">{$message->getLink()->text}</a> </div> {* OR control *} {control flashes} {* ... *}