/** * Method to get a reference to the current view and load it if necessary. * * @param string $name The view name. Optional, defaults to the controller name. * @param string $type The view type. Optional. * @param string $prefix The class prefix. Optional. * @param array $config Configuration array for view. Optional. * * @return JViewLegacy Reference to the view or an error. * * @since 12.2 * @throws Exception */ public function getView($name = '', $type = '', $prefix = '', $config = array()) { // @note We use self so we only access stuff in this class rather than in all classes. if (!isset(self::$views)) { self::$views = array(); } if (empty($name)) { $name = $this->getName(); } if (empty($prefix)) { $prefix = $this->getName() . 'View'; } if (empty(self::$views[$name][$type][$prefix])) { if ($view = $this->createView($name, $prefix, $type, $config)) { self::$views[$name][$type][$prefix] =& $view; } else { $response = 500; /* * With URL rewriting enabled on the server, all client requests for non-existent files are being * forwarded to Joomla. Return a 404 response here and assume the client was requesting a non-existent * file for which there is no view type that matches the file's extension (the most likely scenario). */ if (JFactory::getApplication()->get('sef_rewrite')) { $response = 404; } throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_NOT_FOUND', $name, $type, $prefix), $response); } } return self::$views[$name][$type][$prefix]; }