Created
November 7, 2019 12:10
-
-
Save felixdorn/2c4f62db73ba2805c952658c1017603b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Felix\Framework\Renderer; | |
use Felix\Flash\Flasher; | |
use Tamtamchik\SimpleFlash\Flash; | |
use Twig\Extension\AbstractExtension; | |
use Twig\TwigFunction; | |
class FlashExtension extends AbstractExtension | |
{ | |
public function getFunctions() | |
{ | |
$htmlSafe = [ | |
'is_safe' => [ | |
'html' => true | |
] | |
]; | |
return [ | |
new TwigFunction('getFlashed', [$this, 'getFlashed'], $htmlSafe), | |
new TwigFunction('getFlashedErrors', [$this, 'getFlashedErrors'],$htmlSafe), | |
new TwigFunction('getFlashedSuccess', [$this, 'getFlashedSuccess'], $htmlSafe), | |
new TwigFunction('getFlashedWarning', [$this, 'getFlashedWarning'], $htmlSafe), | |
new TwigFunction('getFlashedInfo', [$this, 'getFlashedInfo'], $htmlSafe), | |
] ; | |
} | |
public function getFlashed() { | |
return Flasher::getInstance()->display(); | |
} | |
public function getFlashedErrors() { | |
return Flasher::getInstance()->display('error'); | |
} | |
public function getFlashedSuccess() | |
{ | |
return Flasher::getInstance()->display('success'); | |
} | |
public function getFlashedWarning() | |
{ | |
return Flasher::getInstance()->display('warning'); | |
} | |
public function getFlashedInfo() | |
{ | |
return Flash::display('info'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment