PHP code example of holabs / flashes

1. Go to this page and download the library: Download holabs/flashes library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

holabs / flashes example snippets



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;
	}
	
	// ...

}
latte
	{* ... *}
	
	{* 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}
	
	{* ... *}