/** * Tells the display backend to show its display * * @param array $view The view to display * @param array $data The data to be used in the view * @return void */ public static function display($view, $data = array()) { // Verify that the display backend has been constructed by the factory. if (null === self::$dispBackend) { throw new ASO_Display_Exception('Backend not created by factory; please run factory first'); } // Verify that backend parameters are in an array. if (!is_array($data)) { throw new ASO_Display_Exception('Display data must be in an array'); } // Verify that an backend name has been specified. if (!is_string($view) || empty($view)) { throw new ASO_Display_Exception('View must be specified in a string'); } self::$dispBackend->runDisplay($view, $data); }
/** * Dispatches an HTTP request to its assigned controller * * @throws ASO_Dispatch_Exception * @return void */ protected function _dispatch() { $this->_loadRouting(); $this->_splitURI(); // Check that controller class exists if (!file_exists('app/controllers/' . $this->action . '.php')) { if ($this->throwExceptions() || !file_exists('app/views/404.tpl')) { header('HTTP/1.1 404 Not Found'); throw new ASO_Dispatch_Exception("Controller ({$this->action}) not found"); } else { header('HTTP/1.1 404 Not Found'); ASO_Display::display('404'); return false; } } // Instantiate the action controller require_once 'controllers/' . $this->action . '.php'; $action = ucfirst($this->action) . '_Controller'; $this->controller = $controller = new $action(array_merge($this->config, array('baseURL' => $this->_baseURL))); // If a method wasn't defined in the URI, grab the default from the controller if ($this->method == '') { $this->method = $controller->defaultMethod; } // Check that method call exists if (!method_exists($controller, $this->method)) { throw new ASO_Dispatch_Exception('Method not found: ' . $action . '::' . $this->method); } // Run the method $controller->{$this->method}($this->extra); $controller->completeDispatch(); // Save the local vars to the controller $controller->action = $this->action; $controller->method = $this->method; $controller->extra = $this->extra; $controller->_baseURL = $this->_baseURL; // Display back to the browser ASO_Display::display($this->action . '/' . $this->method, get_object_vars($controller)); }