当前位置: 首页>>代码示例>>PHP>>正文


PHP BaseElementModel::getElementType方法代码示例

本文整理汇总了PHP中BaseElementModel::getElementType方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel::getElementType方法的具体用法?PHP BaseElementModel::getElementType怎么用?PHP BaseElementModel::getElementType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseElementModel的用法示例。


在下文中一共展示了BaseElementModel::getElementType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepElementContentForSave

 /**
  * Prepares an element's content for being saved to the database.
  *
  * @param BaseElementModel $element
  * @param FieldLayoutModel $fieldLayout
  * @param bool             $validate
  * @return ContentModel
  */
 public function prepElementContentForSave(BaseElementModel $element, FieldLayoutModel $fieldLayout, $validate = true)
 {
     $elementTypeClass = $element->getElementType();
     $elementType = craft()->elements->getElementType($elementTypeClass);
     $content = $element->getContent();
     if ($validate) {
         // Set the required fields from the layout
         $requiredFields = array();
         if ($elementType->hasTitles()) {
             $requiredFields[] = 'title';
         }
         foreach ($fieldLayout->getFields() as $field) {
             if ($field->required) {
                 $requiredFields[] = $field->fieldId;
             }
         }
         if ($requiredFields) {
             $content->setRequiredFields($requiredFields);
         }
     }
     // Give the fieldtypes a chance to clean up the post data
     foreach (craft()->fields->getAllFields() as $field) {
         $fieldType = craft()->fields->populateFieldType($field);
         if ($fieldType) {
             $fieldType->element = $element;
             $handle = $field->handle;
             $content->{$handle} = $fieldType->prepValueFromPost($content->{$handle});
         }
     }
     return $content;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:39,代码来源:ContentService.php

示例2: isFresh

 /**
  * Returns whether this is the first time the element's content has been edited.
  *
  * @return bool
  */
 protected function isFresh()
 {
     // If this is for a Matrix block, we're more interested in its owner
     if (isset($this->element) && $this->element->getElementType() == ElementType::MatrixBlock) {
         $element = $this->element->getOwner();
     } else {
         $element = $this->element;
     }
     return !$element || empty($element->getContent()->id) && !$element->hasErrors();
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:15,代码来源:BaseFieldType.php

示例3: indexElementAttributes

 /**
  * Indexes the attributes of a given element defined by its element type.
  *
  * @param BaseElementModel $element
  * @param string|null      $localeId
  * @return bool Whether the indexing was a success.
  */
 public function indexElementAttributes(BaseElementModel $element, $localeId = null)
 {
     // Get the element type
     $elementTypeClass = $element->getElementType();
     $elementType = craft()->elements->getElementType($elementTypeClass);
     // Does it have any searchable attributes?
     $searchableAttributes = $elementType->defineSearchableAttributes();
     if ($elementType->hasTitles()) {
         $searchableAttributes[] = 'title';
     }
     foreach ($searchableAttributes as $attribute) {
         $value = $element->{$attribute};
         $value = StringHelper::arrayToString($value);
         $this->_indexElementKeywords($element->id, $attribute, '0', $localeId, $value);
     }
     return true;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:24,代码来源:SearchService.php

示例4: updateDescendantSlugsAndUris

 /**
  * Updates an element’s descendants’ slugs and URIs.
  *
  * @param BaseElementModel $element            The element whose descendants should be updated.
  * @param bool             $updateOtherLocales Whether the element’s other locales should also be updated.
  * @param bool             $asTask             Whether the descendants’ slugs and URIs should be updated via a background task.
  *
  * @return null
  */
 public function updateDescendantSlugsAndUris(BaseElementModel $element, $updateOtherLocales = true, $asTask = false)
 {
     $criteria = $this->getCriteria($element->getElementType());
     $criteria->descendantOf = $element;
     $criteria->descendantDist = 1;
     $criteria->status = null;
     $criteria->localeEnabled = null;
     $criteria->locale = $element->locale;
     if ($asTask) {
         $childIds = $criteria->ids();
         if ($childIds) {
             craft()->tasks->createTask('UpdateElementSlugsAndUris', null, array('elementId' => $childIds, 'elementType' => $element->getElementType(), 'locale' => $element->locale, 'updateOtherLocales' => $updateOtherLocales, 'updateDescendants' => true));
         }
     } else {
         $children = $criteria->find();
         foreach ($children as $child) {
             $this->updateElementSlugAndUri($child, $updateOtherLocales, true, false);
         }
     }
 }
开发者ID:harish94,项目名称:Craft-Release,代码行数:29,代码来源:ElementsService.php

示例5: saveElement

 /**
  * Save Element
  *
  * @param array $params Parameters
  *
  * @return BaseElementModel $model
  */
 public function saveElement(BaseElementModel $element, Request $request)
 {
     $element_type = \Craft\craft()->elements->getElementType($element->getElementType());
     $result = $element_type->saveElement($element, null);
     if (!$result) {
         $exception = new RestException();
         $exception->setStatus(400)->setMessage('Element could not be stored.');
         throw $exception;
     }
     \Craft\craft()->content->saveContent($element);
     return $element;
 }
开发者ID:airtype,项目名称:craft-httpmessagesrestmiddleware,代码行数:19,代码来源:ElementService.php

示例6: validateContent

 /**
  * Validates some content with a given field layout.
  *
  * @param BaseElementModel $element The element whose content should be validated.
  *
  * @return bool Whether the element's content validates.
  */
 public function validateContent(BaseElementModel $element)
 {
     $elementType = craft()->elements->getElementType($element->getElementType());
     $fieldLayout = $element->getFieldLayout();
     $content = $element->getContent();
     // Set the required fields from the layout
     $attributesToValidate = array('id', 'elementId', 'locale');
     $requiredFields = array();
     if ($elementType->hasTitles()) {
         $requiredFields[] = 'title';
         $attributesToValidate[] = 'title';
     }
     if ($fieldLayout) {
         foreach ($fieldLayout->getFields() as $fieldLayoutField) {
             $field = $fieldLayoutField->getField();
             if ($field) {
                 $attributesToValidate[] = $field->handle;
                 if ($fieldLayoutField->required) {
                     $requiredFields[] = $field->id;
                 }
             }
         }
     }
     if ($requiredFields) {
         $content->setRequiredFields($requiredFields);
     }
     return $content->validate($attributesToValidate);
 }
开发者ID:kant312,项目名称:sop,代码行数:35,代码来源:ContentService.php

示例7: updateDescendantSlugsAndUris

 /**
  * Updates an element’s descendants’ slugs and URIs.
  *
  * @param BaseElementModel $element The element whose descendants should be updated.
  *
  * @return null
  */
 public function updateDescendantSlugsAndUris(BaseElementModel $element)
 {
     $criteria = $this->getCriteria($element->getElementType());
     $criteria->descendantOf = $element;
     $criteria->descendantDist = 1;
     $criteria->status = null;
     $criteria->localeEnabled = null;
     $children = $criteria->find();
     foreach ($children as $child) {
         $this->updateElementSlugAndUri($child);
     }
 }
开发者ID:kant312,项目名称:sop,代码行数:19,代码来源:ElementsService.php


注:本文中的BaseElementModel::getElementType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。