本文整理匯總了PHP中CModule::getModuleByName方法的典型用法代碼示例。如果您正苦於以下問題:PHP CModule::getModuleByName方法的具體用法?PHP CModule::getModuleByName怎麽用?PHP CModule::getModuleByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CModule
的用法示例。
在下文中一共展示了CModule::getModuleByName方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getModuleName
/**
* Utility function to return the current module name
* It first tries to get the name based on the table name,
* and infer the name from the class name. If neither of these
* are appropriate, children should implement this function themselves.
* or set _module_directory after construction.
*/
public function getModuleName()
{
/* If we've already done this, or our sub-class has set this,
we are on a winner */
if (!empty($this->_module_directory)) {
return $this->_module_directory;
}
/* Now the guessing game begins */
$mods = new CModule();
if (!empty($this->_permission_name)) {
if ($mod_name = $mods->getModuleByName($this->_permission_name)) {
$this->_module_directory = $mod_name;
return $mod_name;
}
}
$class = get_class($this);
// Class usually includes an initial C and is camel case
// And never is multibyte, so we are safe to use the non mb_ functions.
$class = strtolower(substr($class, 1));
if ($mod_name = $mods->getModuleByName($class)) {
$this->_module_directory = $mod_name;
return $mod_name;
}
return 'unknown';
}