本文整理汇总了PHP中i18n::get_owner_module方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::get_owner_module方法的具体用法?PHP i18n::get_owner_module怎么用?PHP i18n::get_owner_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i18n
的用法示例。
在下文中一共展示了i18n::get_owner_module方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getBestModuleForKey
/**
* Determine the best module to be given ownership over this key
*
* @param array $entitiesByModule
* @param string $key
* @return string Best module, if found
*/
protected function getBestModuleForKey($entitiesByModule, $key)
{
// Check classes
$class = current(explode('.', $key));
$owner = i18n::get_owner_module($class);
if ($owner) {
return $owner;
}
// @todo - How to determine ownership of templates? Templates can
// exist in multiple locations with the same name.
// Display notice if not found
Debug::message("Duplicate key {$key} detected in multiple modules with no obvious owner", false);
// Fall back to framework then cms modules
foreach (array('framework', 'cms') as $module) {
if (isset($entitiesByModule[$module][$key])) {
return $module;
}
}
// Do nothing
return null;
}
示例2: provideI18nEntities
/**
* Provide menu titles to the i18n entity provider
*/
function provideI18nEntities()
{
$cmsClasses = self::get_cms_classes();
$entities = array();
foreach ($cmsClasses as $cmsClass) {
$defaultTitle = LeftAndMain::menu_title_for_class($cmsClass);
$ownerModule = i18n::get_owner_module($cmsClass);
$entities["{$cmsClass}.MENUTITLE"] = array($defaultTitle, PR_HIGH, 'Menu title', $ownerModule);
}
return $entities;
}
示例3: findModuleForClass
/**
* Given a partial class name, attempt to determine the best module to assign strings to.
*
* @param string $class Either a FQN class name, or a non-qualified class name.
* @return string Name of module
*/
protected function findModuleForClass($class)
{
if (ClassInfo::exists($class)) {
return i18n::get_owner_module($class);
}
// If we can't find a class, see if it needs to be fully qualified
if (strpos($class, '\\') !== false) {
return null;
}
// Find FQN that ends with $class
$classes = preg_grep('/' . preg_quote("\\{$class}", '\\/') . '$/i', SS_ClassLoader::instance()->getManifest()->getClassNames());
// Find all modules for candidate classes
$modules = array_unique(array_map(function ($class) {
return i18n::get_owner_module($class);
}, $classes));
if (count($modules) === 1) {
return reset($modules);
}
// Couldn't find it! Exists in none, or multiple modules.
return null;
}