本文整理匯總了PHP中JControllerLegacy::addIncludePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP JControllerLegacy::addIncludePath方法的具體用法?PHP JControllerLegacy::addIncludePath怎麽用?PHP JControllerLegacy::addIncludePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JControllerLegacy
的用法示例。
在下文中一共展示了JControllerLegacy::addIncludePath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getController
/**
* KSSystem::getController()
*
* @param mixed $name
* @param mixed $config
* @return
*/
public static function getController($name, $ext_name = null, $config = array())
{
if (empty(self::$ext_name)) {
self::setGlobalVar('ext_name');
}
if (empty(self::$ext_name_com)) {
self::setGlobalVar('ext_name_com');
}
if (!empty($ext_name)) {
$ext_name_com = 'com_' . $ext_name;
if (JFactory::getApplication()->isAdmin()) {
$maincontrollerFile = JPATH_ADMINISTRATOR . DS . 'components' . DS . $ext_name_com . DS . 'controller.php';
} else {
$maincontrollerFile = JPATH_SITE . DS . 'components' . DS . $ext_name_com . DS . 'controller.php';
}
if (file_exists($maincontrollerFile)) {
require_once $maincontrollerFile;
}
} else {
$ext_name = self::$ext_name;
$ext_name_com = self::$ext_name_com;
}
jimport('joomla.application.component.controller');
$controllerFile = JPATH_SITE . DS . 'components' . DS . $ext_name_com . DS . 'controllers' . DS . $name . '.php';
$adminControllerFile = JPATH_ADMINISTRATOR . DS . 'components' . DS . $ext_name_com . DS . 'controllers' . DS . $name . '.php';
if (file_exists($controllerFile)) {
require_once $controllerFile;
} elseif (file_exists($adminControllerFile)) {
require_once $adminControllerFile;
} else {
JControllerLegacy::addIncludePath(JPATH_SITE . DS . 'components' . DS . $ext_name_com . DS . 'controllers');
}
$controller_name = ucfirst($ext_name) . 'Controller';
$controller_name = $controller_name . $name;
$controller = new $controller_name();
return $controller;
}