Created
June 23, 2013 02:43
-
-
Save dshafik/5843549 to your computer and use it in GitHub Desktop.
Add success message to ZfcUser without modifying the ZfcUser code in any way
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 Application; | |
use Zend\Mvc\ModuleRouteListener; | |
use Zend\Mvc\MvcEvent; | |
class Module { | |
public function onBootstrap(MvcEvent $e) | |
{ | |
$eventManager = $e->getApplication()->getEventManager(); | |
$serviceManager = $e->getApplication()->getServiceManager(); // Get the ServiceManager | |
$viewHelperManager = $serviceManager->get('ViewHelperManager'); // This is how we will access the FlashMessenger view helper | |
$moduleRouteListener = new ModuleRouteListener(); | |
$moduleRouteListener->attach($eventManager); | |
$events = $eventManager->getSharedManager(); | |
$events->attach( | |
'ZfcUser\Authentication\Adapter\AdapterChain', // Plugin to the Authentication chain event manager | |
'authenticate', // and hook into the authentication event | |
function ($e) use ($viewHelperManager) { // pass in the ViewHelperManager | |
/* @var $messenger \Zend\View\Helper\FlashMessenger */ | |
$messenger = $viewHelperManager->get('flashmessenger'); // Get the flashmessenger view helper | |
$messenger->getPluginFlashMessenger()->addSuccessMessage("Successfully Logged In!"); // Add the success message | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment