コード例 #1
0
ファイル: Default.php プロジェクト: ClaudioThomas/shopware-4
 /**
  * This method controls the default routing. Don't be called when the
  * Enlight_Controller_Router_Route event canceled the default routing.
  * The default routing uses the dispatcher of the front controller to route
  * the request to the corresponding controller method.
  *
  * @param Enlight_Controller_Request_RequestHttp $request
  * @return array
  */
 public function routeDefault(Enlight_Controller_Request_Request $request)
 {
     $path = trim($request->getPathInfo(), $this->separator);
     if (empty($path)) {
         return array();
     }
     $dispatcher = $this->front->Dispatcher();
     $query = array();
     $params = array();
     foreach (explode($this->separator, $path) as $routePart) {
         $routePart = urldecode($routePart);
         if (empty($query[$request->getModuleKey()]) && $dispatcher->isValidModule($routePart)) {
             $query[$request->getModuleKey()] = $routePart;
         } elseif (empty($query[$request->getControllerKey()])) {
             $query[$request->getControllerKey()] = $routePart;
         } elseif (empty($query[$request->getActionKey()])) {
             $query[$request->getActionKey()] = $routePart;
         } else {
             $params[] = $routePart;
         }
     }
     if ($params) {
         $chunks = array_chunk($params, 2, false);
         foreach ($chunks as $chunk) {
             if (isset($chunk[1])) {
                 $query[$chunk[0]] = $chunk[1];
             } else {
                 $query[$chunk[0]] = '';
             }
         }
     }
     return $query;
 }