public function onPostRoute(MvcEvent $e)
    {
        $matches = $e->getRouteMatch();
        if (!$matches instanceof Router\RouteMatch) {
            // Can't do anything without a route match
            return;
        }
        
    	// Check for 'asset_manager' route
    	$routeName = $matches->getMatchedRouteName();
    	$routeName = explode('/', $routeName, 2);
    	$routeName = $routeName[0];
    	
    	if ($routeName !== 'asset_manager') {
    		// Not an asset request
    		return;
    	}
    	
    	// TODO: Take care of grouped assets (Merged assets)
    	//       Right now only direct access
    	
    	$serviceManager = $e->getApplication()->getServiceManager();
    	$router         = $e->getRouter();
    	$assetManager   = $serviceManager->get('AssetManager');
    	
    	$requestPath     = $e->getRequest()->getUri()->getPath();
    	$requestBasePath = $router->assemble(array(), array('name' => 'asset_manager'));
    	$requestBasePath = $requestBasePath . '/';
   
    	if (strlen($requestPath) <= strlen($requestBasePath)) {
    		// Not enough data!
    		return;
    	}
    	
    	$requestPath = substr($requestPath, strlen($requestBasePath) - 1);
    	
    	$assetPathStack = $serviceManager->get('AssetPathStack');
    	$content = $assetPathStack->resolve($requestPath);  	
    	if (!empty($content)) {
    		$response = $e->getResponse();
    		$headers  = $response->getHeaders();
    		$headers->addHeaderLine('Content-Type', MimeResolver::getMimeType($requestPath));
    		$response->setContent($content);
    		return $response;
    	}
    	
    }
public function onPostRoute(MvcEvent $e)
    {
        $matches = $e->getRouteMatch();
        if (!$matches instanceof Router\RouteMatch) {
            // Can't do anything without a route match
            return;
        }
        
    	// Check for 'asset_manager' route
    	$routeName = $matches->getMatchedRouteName();
    	$routeName = explode('/', $routeName, 2);
    	$routeName = $routeName[0];
    	
    	if ($routeName !== 'asset_manager') {
    		// Not an asset request
    		return;
    	}
    	
    	// TODO: Take care of grouped assets (Merged assets)
    	//       Right now only direct access
    	
    	$serviceManager = $e->getApplication()->getServiceManager();
    	$router         = $e->getRouter();
    	$assetManager   = $serviceManager->get('AssetManager');
    	
    	$requestPath     = $e->getRequest()->getUri()->getPath();
    	$requestBasePath = $router->assemble(array(), array('name' => 'asset_manager'));
    	$requestBasePath = $requestBasePath . '/';
   
    	if (strlen($requestPath) <= strlen($requestBasePath)) {
    		// Not enough data!
    		return;
    	}
    	
    	$requestPath = substr($requestPath, strlen($requestBasePath) - 1);
    	
    	$assetPathStack = $serviceManager->get('AssetPathStack');
    	$content = $assetPathStack->resolve($requestPath);  	
    	if (!empty($content)) {
    		$response = $e->getResponse();
    		$headers  = $response->getHeaders();
    		$headers->addHeaderLine('Content-Type', MimeResolver::getMimeType($requestPath));
    		$response->setContent($content);
    		return $response;
    	}
    	
    }
public function onPostRoute ( MvcEvent $ e ) { $ matches = $ e -> getRouteMatch ( ) ; if ( ! $ matches instanceof Router \ RouteMatch ) { // Can't do anything without a route match return ; } // Check for 'asset_manager' route $ routeName = $ matches -> getMatchedRouteName ( ) ; $ routeName = explode ( '/' , $ routeName , 2 ) ; $ routeName = $ routeName [ 0 ] ; if ( $ routeName !== 'asset_manager' ) { // Not an asset request return ; } // TODO: Take care of grouped assets (Merged assets) //       Right now only direct access $ serviceManager = $ e -> getApplication ( ) -> getServiceManager ( ) ; $ router = $ e -> getRouter ( ) ; $ assetManager = $ serviceManager -> get ( 'AssetManager' ) ; $ requestPath = $ e -> getRequest ( ) -> getUri ( ) -> getPath ( ) ; $ requestBasePath = $ router -> assemble ( array ( ) , array ( 'name' => 'asset_manager' ) ) ; $ requestBasePath = $ requestBasePath . '/' ; if ( strlen ( $ requestPath ) <= strlen ( $ requestBasePath ) ) { // Not enough data! return ; } $ requestPath = substr ( $ requestPath , strlen ( $ requestBasePath ) - 1 ) ; $ assetPathStack = $ serviceManager -> get ( 'AssetPathStack' ) ; $ content = $ assetPathStack -> resolve ( $ requestPath ) ; if ( ! empty ( $ content ) ) { $ response = $ e -> getResponse ( ) ; $ headers = $ response -> getHeaders ( ) ; $ headers -> addHeaderLine ( 'Content-Type' , MimeResolver :: getMimeType ( $ requestPath ) ) ; $ response -> setContent ( $ content ) ; return $ response ; } }
Listen to the "route" event and determine if an asset should be loaded.

@param  MvcEvent $e
@return Response|null
Listen to the route event and determine if an asset should be loaded .