예제 #1
0
 public function pushBindings(BlazeContext $context)
 {
     $requestUri = $context->getRequest()->getRequestURI()->getPath();
     // remove the prefix of the url e.g. BlazeFrameworkServer/
     if (!$requestUri->endsWith('/')) {
         $requestUri = $requestUri->concat('/');
     }
     $requestUri = $requestUri->substring($context->getApplication()->getUrlPrefix()->replace('*', '')->length());
     // Requesturl has always to start with a '/'
     if ($requestUri->length() == 0 || $requestUri->charAt(0) != '/') {
         $requestUri = new String('/' . $requestUri->toNative());
     }
     foreach ($this->mapping as $navigationRule) {
         $regex = '/^' . str_replace(array('/', '*'), array('\\/', '.*'), $navigationRule->getMapping()) . '$/';
         if ($requestUri->matches($regex)) {
             $bindingParts = $requestUri->substring(strlen($navigationRule->getMapping()) - 1)->split('/');
             $count = count($bindingParts);
             $newValue = null;
             // Look for the bindings
             $binds = $navigationRule->getBindings();
             for ($i = 0; $i < $binds->count(); $i++) {
                 if ($i < $count && $bindingParts[$i] != '') {
                     $newValue = $bindingParts[$i];
                 } else {
                     $newValue = $binds->get($i)->getDefault();
                 }
                 if ($newValue !== null) {
                     $binds->get($i)->getReference()->setValue($context, $newValue);
                     $newValue = null;
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * Handle <code>beforePhase</code> <code>PhaseListener</code> events.
  * @param blaze\web\application\BlazeContext $context the FacesContext for the current request
  * @param array[blaze\web\event\PhaseListener] $listenersIterator a ListIterator for the PhaseListeners that need
  *  to be invoked
  * @param blaze\web\event\PhaseEvent $event the event to pass to each of the invoked listeners
  */
 protected function handleBeforePhase(BlazeContext $context, \blaze\collections\Map $listeners, PhaseEvent $event)
 {
     //try {
     //Flash flash = context.getExternalContext().getFlash();
     //flash.doPrePhaseActions(context);
     //} catch (UnsupportedOperationException uoe) {
     //if (LOGGER.isLoggable(Level.FINE)) {
     //LOGGER.fine("ExternalContext.getFlash() throw UnsupportedOperationException -> Flash unavailable");
     //}
     //}
     //RequestStateManager.clearAttributesForPhase(context,
     // context.getCurrentPhaseId());
     $requestUri = $context->getRequest()->getRequestURI()->getPath();
     // remove the prefix of the url e.g. BlazeFrameworkServer/
     if (!$requestUri->endsWith('/')) {
         $requestUri = $requestUri->concat('/');
     }
     $requestUri = $requestUri->substring($context->getApplication()->getUrlPrefix()->replace('*', '')->length());
     // Requesturl has always to start with a '/'
     if ($requestUri->length() == 0 || $requestUri->charAt(0) != '/') {
         $requestUri = new \blaze\lang\String('/' . $requestUri->toNative());
     }
     foreach ($listeners as $pattern => $listener) {
         if (($this->getId() == $listener->getPhaseId() || \blaze\web\event\PhaseId::ANY_PHASE == $listener->getPhaseId()) && $this->matchesPattern($requestUri, $pattern)) {
             try {
                 $listener->beforePhase($event);
             } catch (Exception $e) {
                 $this->queueException($context, $e);
                 //, ExceptionQueuedEventContext.IN_BEFORE_PHASE_KEY);
                 // move the iterator pointer back one
                 //if (listenersIterator.hasPrevious()) {
                 //listenersIterator.previous();
                 //}
                 return;
             }
         }
     }
 }
예제 #3
0
 public function getRequestView(BlazeContext $context)
 {
     $requestUri = $context->getRequest()->getRequestUri()->getPath();
     // remove the prefix of the url e.g. BlazeFrameworkServer/
     if (!$requestUri->endsWith('/')) {
         $requestUri = $requestUri->concat('/');
     }
     $requestUri = $requestUri->substring($context->getApplication()->getUrlPrefix()->replace('*', '')->length());
     // Requesturl has always to start with a '/'
     if ($requestUri->length() == 0 || $requestUri->charAt(0) != '/') {
         $requestUri = new String('/' . $requestUri->toNative());
     }
     foreach ($this->mapping as $navigationRule) {
         $regex = '/^' . str_replace(array('/', '*'), array('\\/', '.*'), $navigationRule->getMapping()) . '$/';
         if ($requestUri->matches($regex)) {
             return $this->getView($context, $navigationRule->getIndexView());
         }
     }
     return null;
 }