Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function toRoute($routeString)
 {
     if (preg_match('/^snippet:([a-z0-9_\\\\]+)(?:\\?(.*))?$/i', $routeString, $matches) !== 1) {
         throw new InvalidRouteException(tr('Invalid route string for snippet dispatcher'));
     }
     $route = array('parameters' => array());
     if (isset($matches[2])) {
         $route['parameters'] = Http::decodeQuery($matches[2], false);
         if (!is_array($route['parameters'])) {
             throw new InvalidRouteException(tr('Invalid JSON parameters in route string'));
         }
     }
     $route['snippet'] = $matches[1];
     return $route;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function toRoute($routeString)
 {
     if (preg_match('/^action:(?:([a-z0-9_\\\\]+)::)?([a-z0-9_\\\\]+)(?:\\?(.*))?$/i', $routeString, $matches) !== 1) {
         throw new InvalidRouteException(tr('Invalid route string for action dispatcher'));
     }
     $route = array('parameters' => array());
     if (isset($matches[3])) {
         $route['parameters'] = Http::decodeQuery($matches[3], false);
         if (!is_array($route['parameters'])) {
             throw new InvalidRouteException(tr('Invalid JSON parameters in route string'));
         }
     }
     if ($matches[1] != '') {
         $route['controller'] = $matches[1];
         $route['action'] = $matches[2];
     } else {
         if (ucfirst($matches[2]) === $matches[2]) {
             $route['controller'] = $matches[2];
         } else {
             if (isset($this->m->Routing->route['controller'])) {
                 $route['controller'] = $this->m->Routing->route['controller'];
             }
             $route['action'] = $matches[2];
         }
     }
     return $route;
 }