本文整理匯總了PHP中BaseElementModel::getContentTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseElementModel::getContentTable方法的具體用法?PHP BaseElementModel::getContentTable怎麽用?PHP BaseElementModel::getContentTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::getContentTable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveContent
/**
* Saves an element's content.
*
* @param BaseElementModel $element The element whose content we're saving.
* @param bool $validate Whether the element's content should be validated first.
* @param bool $updateOtherLocales Whether any non-translatable fields' values should be copied to the
* element's other locales.
*
* @throws Exception
* @return bool Whether the content was saved successfully. If it wasn't, any validation errors will be saved on the
* element and its content model.
*/
public function saveContent(BaseElementModel $element, $validate = true, $updateOtherLocales = true)
{
if (!$element->id) {
throw new Exception(Craft::t('Cannot save the content of an unsaved element.'));
}
$originalContentTable = $this->contentTable;
$originalFieldColumnPrefix = $this->fieldColumnPrefix;
$originalFieldContext = $this->fieldContext;
$this->contentTable = $element->getContentTable();
$this->fieldColumnPrefix = $element->getFieldColumnPrefix();
$this->fieldContext = $element->getFieldContext();
$content = $element->getContent();
if (!$validate || $this->validateContent($element)) {
$this->_saveContentRow($content);
$fieldLayout = $element->getFieldLayout();
if ($fieldLayout) {
if ($updateOtherLocales && craft()->isLocalized()) {
$this->_duplicateNonTranslatableFieldValues($element, $content, $fieldLayout, $nonTranslatableFields, $otherContentModels);
}
$this->_updateSearchIndexes($element, $content, $fieldLayout, $nonTranslatableFields, $otherContentModels);
}
$success = true;
} else {
$element->addErrors($content->getErrors());
$success = false;
}
$this->contentTable = $originalContentTable;
$this->fieldColumnPrefix = $originalFieldColumnPrefix;
$this->fieldContext = $originalFieldContext;
return $success;
}