當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tool::getDefaultLanguage方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:ChristophWurst,項目名稱:pimcore,代碼行數:21,代碼來源:Localizedfield.php

示例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;
 }
開發者ID:krugerke,項目名稱:pimcore,代碼行數:37,代碼來源:Resource.php

示例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;
 }
開發者ID:hagith,項目名稱:pimcore-boilerplate,代碼行數:23,代碼來源:Action.php


注:本文中的Pimcore\Tool::getDefaultLanguage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。