本文整理汇总了PHP中eZContentObject::create方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::create方法的具体用法?PHP eZContentObject::create怎么用?PHP eZContentObject::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instantiate
function instantiate($userID = false, $sectionID = 0, $versionNumber = false, $languageCode = false, $versionStatus = eZContentObjectVersion::STATUS_INTERNAL_DRAFT)
{
$attributes = $this->fetchAttributes();
if ($userID === false) {
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
}
if ($languageCode == false) {
$languageCode = eZContentObject::defaultLanguage();
}
$object = eZContentObject::create(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), $this->attribute("id"), $userID, $sectionID, 1, $languageCode);
if ($this->attribute('always_available')) {
$object->setAttribute('language_mask', (int) $object->attribute('language_mask') | 1);
}
$db = eZDB::instance();
$db->begin();
$object->store();
$object->assignDefaultStates();
$object->setName(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), false, $languageCode);
if (!$versionNumber) {
$version = $object->createInitialVersion($userID, $languageCode);
} else {
$version = eZContentObjectVersion::create($object->attribute("id"), $userID, $versionNumber, $languageCode);
}
if ($versionStatus !== false) {
$version->setAttribute('status', $versionStatus);
}
$version->store();
foreach ($attributes as $attribute) {
$attribute->instantiate($object->attribute('id'), $languageCode);
}
if (isset($user) && $user instanceof eZUser && $user->isAnonymous()) {
$createdObjectIDList = eZPreferences::value('ObjectCreationIDList');
if (!$createdObjectIDList) {
$createdObjectIDList = array($object->attribute('id'));
} else {
$createdObjectIDList = unserialize($createdObjectIDList);
$createdObjectIDList[] = $object->attribute('id');
}
eZPreferences::setValue('ObjectCreationIDList', serialize($createdObjectIDList));
}
$db->commit();
return $object;
}