Skip to content

Instantly share code, notes, and snippets.

@macnibblet
Created June 28, 2012 09:22
Show Gist options
  • Save macnibblet/3010154 to your computer and use it in GitHub Desktop.
Save macnibblet/3010154 to your computer and use it in GitHub Desktop.
<?php
/**
* @author Antoine Hedgecock <antoine@pmg.se>
*/
/**
* @namespace
*/
namespace MCN;
use Zend\ModuleManager\ModuleManager,
Zend\ModuleManager\Feature\ConfigProviderInterface,
Zend\ModuleManager\Feature\AutoloaderProviderInterface;
/**
* @category User
*/
class Module implements ConfigProviderInterface, AutoloaderProviderInterface
{
public function onBootstrap($e)
{
$sm = $e->getApplication()
->getServiceManager();
$sm->get('view_manager')
->getHelperManager()
->addInitializer(function($instance) use ($sm) {
if ($instance instanceof \Zend\ServiceManager\ServiceLocatorAwareInterface) {
$instance->setServiceLocator($sm);
}
})
->setFactory('Zend\View\Helper\Url', function($sm) {
$urlHelper = new \Zend\View\Helper\Url;
$urlHelper->setRouter($sm->get('Router'));
$match = $sm->get('application')
->getMvcEvent()
->getRouteMatch();
if ($match instanceof \Zend\Mvc\Router\RouteMatch) {
$urlHelper->setRouteMatch($match);
}
return $urlHelper;
});
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
'MCN' => __DIR__ . '/src/MCN',
'MCNCore' => __DIR__ . '/src/MCNCore'
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment