Пример #1
0
 public function section($section = null)
 {
     if ($section === null || !method_exists($this, $section)) {
         $this->app->notFound();
     }
     $args = func_get_args();
     array_shift($args);
     dispatchMethod($this, $section, $args);
 }
Пример #2
0
 /**
  * Выполнить метод
  *
  * @param string $method
  * @param array $params
  * @return array
  */
 public function request($method, $params = null)
 {
     $params = (array) $params;
     if (array_key_exists($method, $this->apimap)) {
         $map = $this->apimap[$method];
         $class = array_shift($map);
         $classMethod = array_shift($map);
     } else {
         $class = $this->getClass($method);
         $classMethod = 'invoke';
         $map = array();
     }
     if (!class_exists($class) || !method_exists($class, $classMethod)) {
         return array('error' => array('err_msg' => 'неизвестный метод', 'err_code' => 0, 'method' => $method, 'params' => $params));
     }
     $obj = new $class($params);
     $obj->ignoreValidationErrors();
     dispatchMethod($obj, $classMethod, $map);
     return $obj->getFormatResponse();
 }