예제 #1
0
 public function processRoute($aInfo)
 {
     $info = parent::processRoute($aInfo);
     $event = new ProcessRouteEvent('process-route', ['target' => $this]);
     $event->setRoute($info);
     $this->dispatchEvent($event, ['listener' => [$this, 'onProcessRoute']]);
     $this->dispatchEvent($event);
     return $event->getRoute();
 }
 public function handleProcessRoute(ProcessRouteEvent $aEvt)
 {
     $info = $aEvt->getRoute();
     if (($info['nextRoute'] ?? null) !== null) {
         $prefix = '';
         //if we already have a current page
         if ($currentPageCode = $this->getController()->getHints()->get('pagerPlugin.currentPage.code')) {
             $currentPage = $this->getStubPage($currentPageCode);
             if (!$currentPage) {
                 throw new UnresolvedRouteException("Was routed to page with code '{$currentPageCode}', but could not get stub.");
             }
             //use its url as a prefix to the (sub)url being routed
             $prefix = $currentPage['url'];
         }
         $result = $this->routeUrl($prefix . $info['nextRoute']);
         if ($result) {
             $aEvt->setRoute(array('moduleCode' => $result['page']['module']['code'], 'nextRoute' => $result['nextUrl']));
             $this->getController()->getHints()->set('pagerPlugin.currentPage.code', $result['page']['code']);
         }
     }
 }