本文整理匯總了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();
}