本文整理汇总了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];
}