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


PHP eZContentLanguage::store方法代碼示例

本文整理匯總了PHP中eZContentLanguage::store方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentLanguage::store方法的具體用法?PHP eZContentLanguage::store怎麽用?PHP eZContentLanguage::store使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eZContentLanguage的用法示例。


在下文中一共展示了eZContentLanguage::store方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addLanguage

 /**
  * Adds new language to the site.
  *
  * \param locale Locale code (e.g. 'slk-SK') of language to add.
  * \param name Optional. Name of the language. If not specified, the international language name for the $locale locale
  *             will be used.
  * \return eZContentLanguage object of the added language (or the existing one if specified language has been already used)
  *         or false in case of any error (invalid locale code or already reached eZContentLanguage::maxCount() languages).
  * \static
  */
 static function addLanguage($locale, $name = null)
 {
     $localeObject = eZLocale::instance($locale);
     if (!$localeObject) {
         eZDebug::writeError("No such locale {$locale}!", __METHOD__);
         return false;
     }
     if ($name === null) {
         $name = $localeObject->attribute('intl_language_name');
     }
     $db = eZDB::instance();
     $languages = eZContentLanguage::fetchList(true);
     if ($existingLanguage = eZContentLanguage::fetchByLocale($locale)) {
         eZDebug::writeWarning("Language '{$locale}' already exists!", __METHOD__);
         return $existingLanguage;
     }
     if (count($languages) >= self::maxCount()) {
         eZDebug::writeError('Too many languages, cannot add more!', __METHOD__);
         return false;
     }
     $db->lock('ezcontent_language');
     $idSum = 0;
     foreach ($languages as $language) {
         $idSum += $language->attribute('id');
     }
     // ID 1 is reserved
     $candidateId = 2;
     while ($idSum & $candidateId) {
         $candidateId *= 2;
     }
     $newLanguage = new eZContentLanguage(array('id' => $candidateId, 'locale' => $locale, 'name' => $name, 'disabled' => 0));
     $newLanguage->store();
     $db->unlock();
     eZContentLanguage::fetchList(true);
     // clear the cache
     eZContentCacheManager::clearAllContentCache();
     return $newLanguage;
 }
開發者ID:patrickallaert,項目名稱:ezpublish-legacy-php7,代碼行數:48,代碼來源:ezcontentlanguage.php


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