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


PHP ElementHelper::setNextPrevOnElements方法代码示例

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


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

示例1: getEagerLoadedElements

 /**
  * Returns some eager-loaded elements on a given handle.
  *
  * @param string $handle The handle of the eager-loaded elements
  *
  * @return BaseElementModel[]|null The eager-loaded elements, or null
  */
 public function getEagerLoadedElements($handle)
 {
     if (isset($this->_eagerLoadedElements[$handle])) {
         ElementHelper::setNextPrevOnElements($this->_eagerLoadedElements[$handle]);
         return $this->_eagerLoadedElements[$handle];
     }
     return null;
 }
开发者ID:andyra,项目名称:tes,代码行数:15,代码来源:BaseElementModel.php

示例2: populateElements

 /**
  * Populates element models from a given element query's result set.
  *
  * @param array                $results      The result set of an element query
  * @param ElementCriteriaModel $criteria     The element criteria model
  * @param string               $contentTable The content table that was joined in by buildElementsQuery()
  * @param array                $fieldColumns Info about the content field columns being selected
  *
  * @return BaseElementModel[] The populated element models.
  */
 public function populateElements($results, ElementCriteriaModel $criteria, $contentTable, $fieldColumns)
 {
     $elements = array();
     $locale = $criteria->locale;
     $elementType = $criteria->getElementType();
     $indexBy = $criteria->indexBy;
     foreach ($results as $result) {
         // Do we have a placeholder for this element?
         if (isset($this->_placeholderElements[$result['id']][$locale])) {
             $element = $this->_placeholderElements[$result['id']][$locale];
         } else {
             // Make a copy to pass to the onPopulateElement event
             $originalResult = array_merge($result);
             if ($contentTable) {
                 // Separate the content values from the main element attributes
                 $content = array('id' => isset($result['contentId']) ? $result['contentId'] : null, 'elementId' => $result['id'], 'locale' => $locale, 'title' => isset($result['title']) ? $result['title'] : null);
                 unset($result['title']);
                 if ($fieldColumns) {
                     foreach ($fieldColumns as $column) {
                         // Account for results where multiple fields have the same handle, but from
                         // different columns e.g. two Matrix block types that each have a field with the
                         // same handle
                         $colName = $column['column'];
                         $fieldHandle = $column['handle'];
                         if (!isset($content[$fieldHandle]) || empty($content[$fieldHandle]) && !empty($result[$colName])) {
                             $content[$fieldHandle] = $result[$colName];
                         }
                         unset($result[$colName]);
                     }
                 }
             }
             $result['locale'] = $locale;
             // Should we set a search score on the element?
             if (isset($this->_searchResults[$result['id']])) {
                 $result['searchScore'] = $this->_searchResults[$result['id']];
             }
             $element = $elementType->populateElementModel($result);
             // Was an element returned?
             if (!$element || !$element instanceof BaseElementModel) {
                 continue;
             }
             if ($contentTable) {
                 $element->setContent($content);
             }
             // Fire an 'onPopulateElement' event
             $this->onPopulateElement(new Event($this, array('element' => $element, 'result' => $originalResult)));
         }
         if ($indexBy) {
             $elements[$element->{$indexBy}] = $element;
         } else {
             $elements[] = $element;
         }
     }
     ElementHelper::setNextPrevOnElements($elements);
     // Should we eager-load some elements onto these?
     if ($criteria->with) {
         $this->eagerLoadElements($elementType, $elements, $criteria->with);
     }
     // Fire an 'onPopulateElements' event
     $this->onPopulateElements(new Event($this, array('elements' => $elements, 'criteria' => $criteria)));
     // Fire the criteria's 'onPopulateElements' event
     $criteria->onPopulateElements(new Event($criteria, array('elements' => $elements)));
     return $elements;
 }
开发者ID:andyra,项目名称:tes,代码行数:74,代码来源:ElementsService.php


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