Ejemplo n.º 1
0
 /**
  * Setup the controller.
  */
 private function initiate()
 {
     Hook::run('controller-init');
     if (method_exists($this, 'onControllerPreInit')) {
         $this->onControllerPreInit();
     }
     $class = get_class($this);
     $pos = strrpos($class, '\\');
     $className = substr($class, $pos + 1);
     $this->controller = str_replace('Controller', '', $className);
     $this->values = Communication::getQueryString();
     if (isset($_SERVER['CONTENT_TYPE']) && $_SERVER['CONTENT_TYPE'] == 'application/json') {
         $request_body = file_get_contents('php://input');
         $request_body = $request_body ? $request_body : '{}';
         $_POST = array_merge($_POST, json_decode($request_body, true));
     }
     $this->values = array_merge($this->values, Communication::getFormValues());
     if (method_exists($this, 'onControllerInit')) {
         $this->onControllerInit();
     }
 }