当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentObject::fetchClassAttributes方法代码示例

本文整理汇总了PHP中eZContentObject::fetchClassAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::fetchClassAttributes方法的具体用法?PHP eZContentObject::fetchClassAttributes怎么用?PHP eZContentObject::fetchClassAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZContentObject的用法示例。


在下文中一共展示了eZContentObject::fetchClassAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addTranslation

 /**
  * Adds a new translation and creates a new dedicated fieldset.
  * If $lang is an invalid locale (ie. malformed or not declared in site.ini/RegionalSettings.Locale), will throw a SQLIContentException
  * @param string $lang Translation code to add, as a locale (xxx-XX)
  * @throws SQLIContentException
  */
 public function addTranslation($lang)
 {
     $language = eZContentLanguage::fetchByLocale($lang, true);
     if (!$language instanceof eZContentLanguage) {
         throw new SQLIContentException("Invalid language '{$lang}'. Must be a valid locale declared in site.ini, RegionalSettings.Locale !");
     }
     $db = eZDB::instance();
     $db->begin();
     $version = $this->getCurrentDraft($lang);
     $versionNumber = $version->attribute('version');
     $objectID = $this->contentObject->attribute('id');
     $translatedDataMap = $this->contentObject->fetchDataMap($versionNumber, $lang);
     // Check if data map exists for this language in the current draft
     // Indeed, several translations can be created for only one publication of an object
     if (!$translatedDataMap) {
         $classAttributes = $this->contentObject->fetchClassAttributes();
         foreach ($classAttributes as $classAttribute) {
             // TODO : Check if attribute is translatable
             $classAttribute->instantiate($objectID, $lang, $versionNumber);
         }
         // Now clears in-memory cache for this datamap (it was fetched once above)
         // Then re-fetch the newly created translated data map
         global $eZContentObjectDataMapCache;
         unset($eZContentObjectDataMapCache[$objectID][$versionNumber][$lang]);
         unset($this->contentObject->ContentObjectAttributes[$versionNumber][$lang]);
         unset($this->contentObject->DataMap[$versionNumber][$lang]);
         $translatedDataMap = $this->contentObject->fetchDataMap($versionNumber, $lang);
     }
     $version->setAttribute('initial_language_id', $language->attribute('id'));
     $version->updateLanguageMask();
     $version->store();
     $db->commit();
     $set = SQLIContentFieldset::fromDataMap($translatedDataMap);
     $set->setLanguage($lang);
     $this->fieldsets[$lang] = $set;
     $this->initIterator();
 }
开发者ID:lolautruche,项目名称:sqliimport,代码行数:43,代码来源:sqlicontentfieldsetholder.php


注:本文中的eZContentObject::fetchClassAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。