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; } } } } }