Ejemplo n.º 1
0
 public function dispatch()
 {
     $response = array();
     $this->router->setRoute($this->request->route);
     $this->router->execute();
     if ($this->getRouter()->controller && $this->getRouter()->action) {
         $controller = $this->getModule($this->getRouter()->controller);
         if (method_exists($controller, $this->getRouter()->action) or method_exists($controller, '__call')) {
             // setup model
             $controller->process = !empty($_POST);
             if (!empty($controller->model)) {
                 $controller->model->setStates($this->request->getQuery());
                 $controller->model->setAttributes($this->request->getData());
             }
             // run action
             $this->reflection->setObject($controller);
             $this->reflection->setMethod($this->router->action);
             $response = $this->reflection->launch($this->router->parameter);
             $this->actionResponse = $response;
         }
     }
     if (!empty($controller->model)) {
         if (!empty($response['errors']) && is_array($response['errors'])) {
             $response['errors'] = array_merge($response['errors'], $controller->model->getErrors());
         } else {
             $response['errors'] = $controller->model->getErrors();
         }
         $response['states'] = $controller->model->getStates();
         $response['attributes'] = $controller->model->getAttributes();
     }
     $this->response->fromArray($response);
 }
Ejemplo n.º 2
0
 protected function factory($setting)
 {
     $this->reflection->setObject($this->getDatabaseAdapter());
     $this->reflection->setMethod('factory');
     return $this->reflection->launch($setting);
 }