Skip to content

Instantly share code, notes, and snippets.

@Freeaqingme
Created September 9, 2012 16:05
Show Gist options
  • Save Freeaqingme/3685297 to your computer and use it in GitHub Desktop.
Save Freeaqingme/3685297 to your computer and use it in GitHub Desktop.
<?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