public function onPreRoute(MvcEvent $event)
    {
    	// Get the router object
    	$serviceManager = $event->getApplication()->getServiceManager();
    	$router         = $event->getRouter();
    	
    	// Load the route configuration
    	$config = $serviceManager->get('Config');
	    $config = isset($config['asset_manager']) && (is_array($config['asset_manager']) || $config['asset_manager'] instanceof ArrayAccess)
	              ? $config['asset_manager']
	              : array();
	    $config = isset($config['routes']) && (is_array($config['routes']) || $config['routes'] instanceof ArrayAccess)
	              ? $config['routes']
	              : array();
	    
	    // There can be special routes defined:
	    //    /css
	    //    /js
	    //    ...
	    // This way the asset manager can be hidden
	    if (!empty($config)) {
	    	// Rename all routes so I get an easy base route 
	    	// name called 'asset_manager'
		    $keys   = array_keys($config);
		    array_walk($keys, function($n) {
		    	$n = 'asset_manager/' . $n;
		    });
		    $config = array_combine($keys, array_values($config));
		    
		    // Add the routes
    		$router->addRoutes($config);
	    } else {
	    	// No routes have been configured!
	    	// So I need to create my own
	    	$router->addRoute(
    			'asset_manager',
	    		array(
	    			'type' => 'Zend\Mvc\Router\Http\Literal',
	                'options' => array(
	                    'route'    => '/assets',
	                ),
	                'may_terminate' => true,
	                'child_routes' => array(
	                	'default' => array(
	                		'type' => 'Wildcard'
	                	)
	                )
	    		)
	    	);
	    }
    }
public function onPreRoute(MvcEvent $event)
    {
    	// Get the router object
    	$serviceManager = $event->getApplication()->getServiceManager();
    	$router         = $event->getRouter();
    	
    	// Load the route configuration
    	$config = $serviceManager->get('Config');
	    $config = isset($config['asset_manager']) && (is_array($config['asset_manager']) || $config['asset_manager'] instanceof ArrayAccess)
	              ? $config['asset_manager']
	              : array();
	    $config = isset($config['routes']) && (is_array($config['routes']) || $config['routes'] instanceof ArrayAccess)
	              ? $config['routes']
	              : array();
	    
	    // There can be special routes defined:
	    //    /css
	    //    /js
	    //    ...
	    // This way the asset manager can be hidden
	    if (!empty($config)) {
	    	// Rename all routes so I get an easy base route 
	    	// name called 'asset_manager'
		    $keys   = array_keys($config);
		    array_walk($keys, function($n) {
		    	$n = 'asset_manager/' . $n;
		    });
		    $config = array_combine($keys, array_values($config));
		    
		    // Add the routes
    		$router->addRoutes($config);
	    } else {
	    	// No routes have been configured!
	    	// So I need to create my own
	    	$router->addRoute(
    			'asset_manager',
	    		array(
	    			'type' => 'Zend\Mvc\Router\Http\Literal',
	                'options' => array(
	                    'route'    => '/assets',
	                ),
	                'may_terminate' => true,
	                'child_routes' => array(
	                	'default' => array(
	                		'type' => 'Wildcard'
	                	)
	                )
	    		)
	    	);
	    }
    }
public function onPreRoute ( MvcEvent $ event ) { // Get the router object $ serviceManager = $ event -> getApplication ( ) -> getServiceManager ( ) ; $ router = $ event -> getRouter ( ) ; // Load the route configuration $ config = $ serviceManager -> get ( 'Config' ) ; $ config = isset ( $ config [ 'asset_manager' ] ) && ( is_array ( $ config [ 'asset_manager' ] ) || $ config [ 'asset_manager' ] instanceof ArrayAccess ) ? $ config [ 'asset_manager' ] : array ( ) ; $ config = isset ( $ config [ 'routes' ] ) && ( is_array ( $ config [ 'routes' ] ) || $ config [ 'routes' ] instanceof ArrayAccess ) ? $ config [ 'routes' ] : array ( ) ; // There can be special routes defined: //    /css //    /js //    ... // This way the asset manager can be hidden if ( ! empty ( $ config ) ) { // Rename all routes so I get an easy base route  // name called 'asset_manager' $ keys = array_keys ( $ config ) ; array_walk ( $ keys , function ( $ n ) { $ n = 'asset_manager/' . $ n ; } ) ; $ config = array_combine ( $ keys , array_values ( $ config ) ) ; // Add the routes $ router -> addRoutes ( $ config ) ; } else { // No routes have been configured! // So I need to create my own $ router -> addRoute ( 'asset_manager' , array ( 'type' => 'Zend\Mvc\Router\Http\Literal' , 'options' => array ( 'route' => '/assets' , ) , 'may_terminate' => true , 'child_routes' => array ( 'default' => array ( 'type' => 'Wildcard' ) ) ) ) ; } }
Late-binding asset routes.

@param MvcEvent $event
Late - binding asset routes .