Module.php
public function routeSave(MvcEvent $event)
    {
        $match = $event->getRouteMatch();
        if(!$match) {
            return;
        }
    
        if($event->getParam('route-cached') || !$event->getParam('route-cacheable')) {
            return;
        }
    
        $path = $event->getRequest()
                      ->getUri()
                      ->getPath();
    
        // save the route match into the cache.
        $cache = $event->getApplication()->getServiceManager()->get('var-cache');
        $cacheKey = $this->getCacheKey($path);
        $data = array (
            'name'  => $event->getRouteMatch()->getMatchedRouteName(),
            'route' => $path,
            'defaults' => $event->getRouteMatch()->getParams(),
        );
        $cache->setItem($cacheKey, $data);
    }
public function routeSave(MvcEvent $event)
    {
        $match = $event->getRouteMatch();
        if(!$match) {
            return;
        }
    
        if($event->getParam('route-cached') || !$event->getParam('route-cacheable')) {
            return;
        }
    
        $path = $event->getRequest()
                      ->getUri()
                      ->getPath();
    
        // save the route match into the cache.
        $cache = $event->getApplication()->getServiceManager()->get('var-cache');
        $cacheKey = $this->getCacheKey($path);
        $data = array (
            'name'  => $event->getRouteMatch()->getMatchedRouteName(),
            'route' => $path,
            'defaults' => $event->getRouteMatch()->getParams(),
        );
        $cache->setItem($cacheKey, $data);
    }
public function routeSave ( MvcEvent $ event ) { $ match = $ event -> getRouteMatch ( ) ; if ( ! $ match ) { return ; } if ( $ event -> getParam ( 'route-cached' ) || ! $ event -> getParam ( 'route-cacheable' ) ) { return ; } $ path = $ event -> getRequest ( ) -> getUri ( ) -> getPath ( ) ; // save the route match into the cache. $ cache = $ event -> getApplication ( ) -> getServiceManager ( ) -> get ( 'var-cache' ) ; $ cacheKey = $ this -> getCacheKey ( $ path ) ; $ data = array ( 'name' => $ event -> getRouteMatch ( ) -> getMatchedRouteName ( ) , 'route' => $ path , 'defaults' => $ event -> getRouteMatch ( ) -> getParams ( ) , ) ; $ cache -> setItem ( $ cacheKey , $ data ) ; }
Method that tries to save a route match into a cache system
@param MvcEvent $event
Method that tries to save a route match into a cache system