当前位置: 首页>>代码示例>>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;未经允许,请勿转载。