Example #1
0
 /**
  * Decode current request URI into a usable RouteMethod.<br />
  * It's then possible to retreive the method to call and the arguments via the following getters:<br />
  * RouteMethod->getMethod();<br />
  * RouteMethod->getArgs();<br />
  * RouteMethod->getURI();<br />
  *
  * @return RouteMethod
  * @see RouteMethod
  */
 public function decode()
 {
     $uri = Context::getModuleURI();
     $matches = array();
     if ($uri == '' || $uri == '/') {
         return new RouteMethod($this->defaultMethod, null, $uri);
     }
     foreach ($this->rules as $regex => $method) {
         if (preg_match(Tools::translateRegex($regex) . 'six', $uri, $matches)) {
             array_shift($matches);
             return new RouteMethod($method, $matches, $uri);
         }
     }
     return new RouteMethod($this->errorMethod, array(self::E_NORULE), $uri);
 }