當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BaseElementModel::getFieldContext方法代碼示例

本文整理匯總了PHP中BaseElementModel::getFieldContext方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseElementModel::getFieldContext方法的具體用法?PHP BaseElementModel::getFieldContext怎麽用?PHP BaseElementModel::getFieldContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BaseElementModel的用法示例。


在下文中一共展示了BaseElementModel::getFieldContext方法的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;
 }
開發者ID:kant312,項目名稱:sop,代碼行數:43,代碼來源:ContentService.php


注:本文中的BaseElementModel::getFieldContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。