-
-
Save andriesss/3685307 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Zend Framework (http://framework.zend.com/) | |
* | |
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository | |
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) | |
* @license http://framework.zend.com/license/new-bsd New BSD License | |
*/ | |
namespace Application; | |
use Zend\Mvc\ModuleRouteListener; | |
use Zend\ModuleManager\ModuleManager; | |
use \Zend\Mvc\MvcEvent; | |
class Module | |
{ | |
public function onBootstrap($e) | |
{ | |
$e->getApplication()->getServiceManager()->get('translator'); | |
$eventManager = $e->getApplication()->getEventManager(); | |
$moduleRouteListener = new ModuleRouteListener(); | |
$moduleRouteListener->attach($eventManager); | |
} | |
public function getConfig() | |
{ | |
return include __DIR__ . '/config/module.config.php'; | |
} | |
public function getAutoloaderConfig() | |
{ | |
return array( | |
'Zend\Loader\StandardAutoloader' => array( | |
'namespaces' => array( | |
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, | |
), | |
), | |
); | |
} | |
public function init(ModuleManager $moduleManager) | |
{ | |
$sharedEvents = $moduleManager->getEventManager()->getSharedManager(); | |
$sharedEvents->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH, function($e) { | |
/** @var $e \Zend\Mvc\MvcEvent */ | |
$matches = $e->getRouteMatch(); | |
$controller = $matches->getParam('controller'); | |
$action = $matches->getParam('action', 'index'); | |
/* $auth = $sm->get('zfcuser_auth_service'); | |
if ($auth->hasIdentity()) { | |
return; | |
} | |
*/ | |
if ($controller == 'zfcuser' && ($action == 'register') || $action == 'login') { | |
return null; | |
} | |
/** @var $response \Zend\Http\PhpEnvironment\Response */ | |
$response = $e->getResponse(); | |
if ($response instanceof \Zend\Http\Response) { | |
$response->getHeaders()->addHeaderLine('Location', 'http://disneyland.com'); | |
$response->setStatusCode(302); | |
return $e->stopPropagation(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment