Created
September 9, 2012 16:05
-
-
Save Freeaqingme/3685297 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 | |
/** | |
* 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\EventManager\StaticEventManager; | |
use Zend\Mvc\MvcEvent; | |
use Zend\Http\Response; | |
class Module | |
{ | |
public function onBootstrap($e) | |
{ | |
$e->getApplication()->getServiceManager()->get('translator'); | |
$eventManager = $e->getApplication()->getEventManager(); | |
$moduleRouteListener = new ModuleRouteListener(); | |
$moduleRouteListener->attach($eventManager); | |
$eventManager->attach('dispatch', array($this, 'checkAcl'), 100); | |
} | |
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 checkAcl(MvcEvent $e) | |
{ | |
$app = $e->getTarget(); | |
$sm = $app->getServiceManager(); | |
$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; | |
} | |
$response = Response::fromString("HTTP/1.1 307\nLocation:/user/login"); | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment