class = false; $this->path = $path; $project = Project::load($app); if (strpos($project['path'], 'http') === 0) { $this->class = $project; } else { $this->class = Library::load($class, $app, $path); } } public function __call($method, $param) { return $this->loadDevelop($method, $param); } public function loadDevelop($method, $param) { if (is_array($this->class)) { return $this->loadServer(); } if ($this->path == 'api') { if (method_exists($this->class, $method . '_secure')) { $key = false; $token = $method . '_token'; if (method_exists($this->class, $token)) { $key = $this->class->{$token}(); } \Dever\Helper\Secure::check($param, 300, $key); } if ($param && is_array($param) && !isset($param[0])) { $reflectionMethod = new \ReflectionMethod($this->class, $method); $data = $reflectionMethod->getParameters(); $result = array(); foreach ($data as $k => $v) { $name = $v->name; if (isset($param[$name])) { $result[] = $param[$name]; } } $param = $result; } else { if (!is_array($param)) { $param = array($param); } } } return $this->loadDevelopCommit($method, $param); } private function loadDevelopCommit($method, $param) { if (method_exists($this->class, $method . '_cmd') && DEVER_PROTO != 'cmd') { Dever::error('route error'); } if (method_exists($this->class, $method . '_commit') && Dever::$commit) { $db = Dever::store(); try { Dever::$commit = false; $db->begin(); $data = $this->loadDevelopMethod($method, $param); $db->commit(); return $data; } catch (\Exception $e) { $db->rollBack(); $data = $e->getTrace(); Debug::trace($data); throw new \Exception(json_encode($data)); } } else { return $this->loadDevelopMethod($method, $param); } } private function loadServer() { return 'error'; } private function loadDevelopMethod($method, $param) { $data = $this->class->$method(...$param); Debug::lib($this->class, $method); Dever::reset(); return $data; } }