本文整理汇总了PHP中Pimcore\Tool::getDefaultLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::getDefaultLanguage方法的具体用法?PHP Tool::getDefaultLanguage怎么用?PHP Tool::getDefaultLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool
的用法示例。
在下文中一共展示了Tool::getDefaultLanguage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLanguage
/**
* @throws \Exception
* @param null $language
* @return string
*/
public function getLanguage($language = null)
{
if ($language) {
return (string) $language;
}
// try to get the language from the registry
try {
$locale = \Zend_Registry::get("Zend_Locale");
if (Tool::isValidLanguage((string) $locale)) {
return (string) $locale;
}
throw new \Exception("Not supported language");
} catch (\Exception $e) {
return Tool::getDefaultLanguage();
}
}
示例2: getTableName
/**
* @return string
* @throws \Exception
* @throws \Zend_Exception
*/
protected function getTableName()
{
if (empty($this->tableName)) {
// default
$this->tableName = "object_" . $this->model->getClassId();
if (!$this->model->getIgnoreLocalizedFields()) {
$language = null;
// check for a localized field and if they should be used for this list
if (property_exists("\\Pimcore\\Model\\Object\\" . ucfirst($this->model->getClassName()), "localizedfields")) {
if ($this->model->getLocale()) {
if (Tool::isValidLanguage((string) $this->model->getLocale())) {
$language = (string) $this->model->getLocale();
}
}
if (!$language && \Zend_Registry::isRegistered("Zend_Locale")) {
$locale = \Zend_Registry::get("Zend_Locale");
if (Tool::isValidLanguage((string) $locale)) {
$language = (string) $locale;
}
}
if (!$language) {
$language = Tool::getDefaultLanguage();
}
if (!$language) {
throw new \Exception("No valid language/locale set. Use \$list->setLocale() to add a language to the listing, or register a global locale");
}
$this->tableName = "object_localized_" . $this->model->getClassId() . "_" . $language;
}
}
}
return $this->tableName;
}
示例3: detectLanguage
/**
* Detect and return user language.
*
* @return string|null
*/
protected function detectLanguage()
{
// check force switch
$lang = $this->getForcedLanguage();
if (!$lang) {
$lang = $this->getPreferredLanguage();
}
if (!$lang) {
// check user browser
$lang = $this->getBrowserLanguage();
}
if (!$lang) {
// use default
$lang = Tool::getDefaultLanguage();
}
$this->setPreferredLanguage($lang);
return $lang;
}