/** * Create URI object which determines dispatch method and * perform dispatch * * @param bool $fake * * @return void */ public function dispatch($fake = false) { $this->uri = new URI($this->defaultModule, $this->dynamicModule); $error = $this->uri->getError(); if ($error == URI::MISSING_CLASS && isset($this->dynamicModule) && $this->dynamicModule != '') { $error = $this->uri->dynamicSection(); } if ($error > 0) { if ($this->environment == 'prod' || $this->debug_mode == false) { if ($error == URI::MISSING_CLASS || $error == URI::MISSING_EVENT_DEF || $error == URI::ERROR_404) { throw new RequestException('Not found', RequestException::NOT_FOUND); } } else { throw new Exception('Dispatch error ' . $error . ' : ' . $this->uri->getErrorMessage()); } } $controller_name = $this->uri->getControllerName(); $this->controller = new $controller_name($this); $this->plugin_manager->preEvent(); if ($fake == false) { $event_val = $this->controller->{$_GET}['event'](); if ($this->mvc->hasErrors()) { throw new ErrorException($this->mvc->errorsToString()); } elseif ($event_val !== false) { if ($this->uri->getInternal()) { $this->controller->setTemplate('empathy.tpl'); $this->display(true); } else { $this->display(false); } } } }