Пример #1
0
 /**
  *
  * @return array
  */
 protected function _setupParams()
 {
     if (count($this->_matches) < 2) {
         return;
     }
     $params = array();
     array_shift($this->_matches);
     $matchesCount = count($this->_matches);
     $paramValues = array_values((array) $this->_paramsList);
     $namesCount = count($paramValues);
     if ($matchesCount < $namesCount) {
         $tmp = array_fill(0, $namesCount - $matchesCount, null);
         $this->_matches = array_merge($this->_matches, $tmp);
     } else {
         if ($matchesCount > $namesCount) {
             $paramValues = range($namesCount, $matchesCount - 1);
         }
     }
     $combination = array_combine($paramValues, $this->_matches);
     if (true === function_exists("array_replace")) {
         $params = array_replace($params, $combination);
     } else {
         $params = Yasc_Util::arrayReplace($params, $combination);
     }
     $pairs = array();
     foreach ($params as $index => $param) {
         if (false === strpos($param, $this->_request->getUrlDelimiter())) {
             continue;
         }
         $dobleAsteriskParam = $param;
         unset($params[$index]);
         $pairs = array_merge($pairs, explode($this->_request->getUrlDelimiter(), $dobleAsteriskParam));
     }
     // get params by pairs, like zend framework does,
     // param1/value1/param2/value2, param1 will be the key of the param,
     // value1 the value of param1, if the value is not present NULL is his
     // value.
     //
     // Check Zend_Controller_Router_Route_Module#match method and see how
     // this works.
     if (($n = count($pairs)) > 0) {
         for ($i = 0; $i < $n; $i = $i + 2) {
             $key = urldecode($pairs[$i]);
             $val = isset($pairs[$i + 1]) ? urldecode($pairs[$i + 1]) : null;
             $params[$key] = isset($params[$key]) ? array_merge((array) $params[$key], array($val)) : $val;
         }
     }
     return $params;
 }
Пример #2
0
 /**
  * @param string $path
  * @param array $options
  * @return string
  */
 public function urlFor($path, array $options = null)
 {
     $result = $this->_request->buildUrl(null, $path, $options);
     return $result["url"];
 }