Last active
December 19, 2015 19:58
-
-
Save cobyl/6009624 to your computer and use it in GitHub Desktop.
Dodanie do nawigacji zalolguj/wyloguj zależnie
od tego czy jest się zalogowanym.
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 | |
public function onBootstrap(MvcEvent $e) { | |
if ($e->getApplication()->getServiceManager()->get('AuthStorage')->hasIdentity()) | |
$pages = new \Zend\Navigation\Page\Mvc(array( | |
'pages'=> | |
array( | |
'auth-user-logout' => array( | |
'label' => 'Wylogowanie', | |
'route' => 'auth-user-login', | |
) | |
) | |
)); | |
else | |
$pages = new \Zend\Navigation\Page\Mvc(array( | |
'pages'=> | |
array( | |
'auth-user-login' => array( | |
'label' => 'Logowanie', | |
'route' => 'auth-user-login', | |
) | |
) | |
)); | |
/** | |
* @var $navigation \Zend\Navigation\Navigation | |
*/ | |
$navigation = $e->getApplication()->getServiceManager()->get('Navigation'); | |
$routeMatch = $e->getRouteMatch(); | |
$router = $e->getRouter(); | |
$pages->setRouteMatch($routeMatch); | |
$pages->setDefaultRouter($router); | |
$navigation->addPages($pages); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment