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;
                 }
             }
         }
     }
 }
Exemple #2
0
 /**
  * Appends a value to a property if it already exists with a delimiter
  *
  * If the property does not, it just adds it.
  * 
  * @param string $key
  * @param mixed $value
  * @param string $delimiter
  */
 public function append(\blaze\lang\String $key, \blaze\lang\String $value, \blaze\lang\String $delimiter = null)
 {
     if ($delimiter === null) {
         $delimiter = new \blaze\lang\String(',');
     }
     $newValue = $value;
     if (isset($this->properties[$key]) && !empty($this->properties[$key])) {
         $newValue = $this->properties[$key] . $delimiter . $value;
     }
     $this->properties[$key->toNative()] = \blaze\lang\String::asWrapper($newValue);
 }
 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;
 }