public function navigate(BlazeContext $context, $action) { $actionString = String::asWrapper($action); $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)) { if ($actionString != null) { // Look for the action in the navigationMap foreach ($navigationRule->getActions() as $action => $view) { if ($actionString->compareTo($action) == 0) { // \blaze\util\Logger::get()->log('Navigated from '.$context->getViewRoot()->getViewId().' to '. $context->getViewHandler()->getView($context, $action['view'])->getViewId()); $context->setViewRoot($context->getViewHandler()->getView($context, $view)); $context->setNavigated(); return; } } } } } $view = $context->getViewHandler()->getView($context, $actionString); if ($view != null) { $context->setViewRoot($view); $context->setNavigated(); } }