本文整理匯總了PHP中JControllerLegacy::views方法的典型用法代碼示例。如果您正苦於以下問題:PHP JControllerLegacy::views方法的具體用法?PHP JControllerLegacy::views怎麽用?PHP JControllerLegacy::views使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JControllerLegacy
的用法示例。
在下文中一共展示了JControllerLegacy::views方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getView
/**
* 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];
}