public static function dispatch($params, &$tree)
 {
     foreach (self::$dispatchRoute as $key => $manual) {
         if (array_key_exists($key, $params) && $params[$key] !== '') {
             if (!isset($params['resource'])) {
                 $params['resource'] = self::$currentResource;
             } else {
                 self::$currentResource = $params['resource'];
             }
             if (!isset($params['model'])) {
                 $params['model'] = self::$currentModel;
             } else {
                 self::$currentModel = $params['model'];
             }
             $interpreter = new Interpreter($params, $tree, Manual::get($manual), true);
             $interpreter->interprete();
             break;
         }
     }
 }
 public function interprete()
 {
     $params = $this->params;
     //var_dump($params);
     foreach ($this->manual as $rule) {
         $key = $rule->key;
         if ($rule->type === 'interpreter') {
             $manual = $rule->desc;
             $params = $this->filterParams($key);
             if (count($params) === 0) {
                 continue;
             }
             if (isset($rule->isArray) && $rule->isArray === true && is_array($params[$key])) {
                 $params = $params[$key];
                 foreach ($params as $param) {
                     $p = array($key => $param);
                     $interpreter = new Interpreter($p, $this->startNode, Manual::get($manual));
                     $interpreter->interprete();
                 }
             } else {
                 $interpreter = new Interpreter($params, $this->startNode, Manual::get($manual));
                 $interpreter->interprete();
             }
         } else {
             if ($rule->type === 'global') {
                 $this->setAttr($key, Configuration::get($key));
             } else {
                 if (array_key_exists($key, $params)) {
                     if (isset($params[$key]) && $params[$key] !== null) {
                         switch ($rule->type) {
                             case 'token':
                                 $attr = is_null($rule->desc) ? $key : $rule->desc;
                                 $this->setAttr($attr, $params[$key]);
                                 break;
                             case 'rule':
                                 $attrList = explode(' ', $rule->desc);
                                 $valueList = explode(' ', $params[$key], count($attrList));
                                 while ($attr = array_shift($attrList)) {
                                     $value = array_shift($valueList);
                                     $this->setAttr($attr, $value);
                                 }
                                 break;
                         }
                     }
                 }
             }
         }
     }
 }