本文整理汇总了PHP中eZContentObject::createNewVersionIn方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::createNewVersionIn方法的具体用法?PHP eZContentObject::createNewVersionIn怎么用?PHP eZContentObject::createNewVersionIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::createNewVersionIn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTranslation
/**
* Adds a translation in language $newLanguageCode for object
*
* @param string $newLanguageCode
* @param mixed $translationData array( attribute identifier => attribute value )
* @return void
*/
public function addTranslation($newLanguageCode, $translationData)
{
// Make sure to refresh the objects data.
$this->refresh();
$this->object->cleanupInternalDrafts();
$version = $this->object->createNewVersionIn($newLanguageCode);
$version->setAttribute('status', eZContentObjectVersion::STATUS_INTERNAL_DRAFT);
$version->store();
$newVersion = $this->object->version($version->attribute('version'));
$newVersionAttributes = $newVersion->contentObjectAttributes($newLanguageCode);
$versionDataMap = self::createDataMap($newVersionAttributes);
// Start updating new version
$version->setAttribute('modified', time());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$db = eZDB::instance();
$db->begin();
$version->store();
// @TODO: Add generic datatype support here
foreach ($translationData as $attr => $value) {
if ($versionDataMap[$attr]->attribute('data_type_string') == "ezxmltext") {
$value = $this->processXmlTextData($value, $versionDataMap[$attr]);
}
$versionDataMap[$attr]->setAttribute('data_text', $value);
$versionDataMap[$attr]->store();
}
$db->commit();
//Update the content object name
$db->begin();
$this->object->setName($this->class->contentObjectName($this->object, $version->attribute('version'), $newLanguageCode), $version->attribute('version'), $newLanguageCode);
$db->commit();
// Finally publish object
self::publishContentObject($this->object, $version);
}
示例2: getCurrentDraft
/**
* Returns current draft for current content object.
* If there is no current draft, a new one will be created in provided language.
* @param string|bool $lang Valid locale xxx-XX. If not provided, default edit language will be used
* @see eZContentObject::createNewVersionIn()
* @return eZContentObjectVersion
*/
public function getCurrentDraft($lang = false)
{
$currentDraft = null;
$db = eZDB::instance();
// First check if we already have a draft
$aFilter = array('contentobject_id' => $this->contentObject->attribute('id'), 'status' => array(array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT)));
$res = eZContentObjectVersion::fetchFiltered($aFilter, null, null);
if (count($res) > 0 && $res[0] instanceof eZContentObjectVersion) {
$currentDraft = $res[0];
// FIXME : Fetch may result several drafts. We should take the last one (highest version)
$currentDraft->setAttribute('modified', eZDateTime::currentTimeStamp());
$currentDraft->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$currentDraft->store();
} else {
$db->begin();
$currentDraft = $this->contentObject->createNewVersionIn($lang, false, $this->contentObject->attribute('current_version'));
$currentDraft->store();
$db->commit();
}
return $currentDraft;
}