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


PHP SS_List::map方法代码示例

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


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

示例1: __construct

 /**
  * @param string $name
  * @param string $title
  * @param DataObjectInterface $object
  * @param string $sort
  * @param SS_List $source
  * @param string $titleField
  */
 public function __construct($name, $title, DataObjectInterface $object, $sort = false, SS_List $source = null, $titleField = 'Title')
 {
     $this->setSort($sort);
     if ($object->many_many($name)) {
         $dataSource = $object->{$name}();
         // Check if we're dealing with an UnsavedRelationList
         $unsaved = $dataSource instanceof UnsavedRelationList;
         // Store the relation's class name
         $class = $dataSource->dataClass();
         $this->dataClass = $class;
         // Sort the items
         if ($this->getSort()) {
             $dataSource = $dataSource->sort($this->getSort());
         }
         // If we're dealing with an UnsavedRelationList, it'll be empty, so we
         // can skip this and just use an array of all available items
         if ($unsaved) {
             $dataSource = $class::get()->map()->toArray();
         } else {
             // If we've been given a list source, filter on those IDs only.
             if ($source) {
                 $dataSource = $dataSource->filter('ID', $source->column('ID'));
             }
             // Start building the data source from scratch. Currently selected items first,
             // in the correct sort order
             $dataSource = $dataSource->map('ID', $titleField)->toArray();
             // Get the other items
             $theRest = $class::get();
             // Exclude items that we've already found
             if (!empty($dataSource)) {
                 $theRest = $theRest->exclude('ID', array_keys($dataSource));
             }
             // If we've been given a list source, filter on those IDs only
             if ($source) {
                 $theRest = $theRest->filter('ID', $source->column('ID'));
             }
             $theRest = $theRest->map('ID', $titleField)->toArray();
             // ... we then add the remaining items in whatever order they come
             $dataSource = $dataSource + $theRest;
         }
     } elseif ($source instanceof SS_List) {
         $dataSource = $source->map('ID', $titleField)->toArray();
     } elseif (is_array($source) && ArrayLib::is_associative($source)) {
         $dataSource = $source;
     } else {
         user_error('MultiSelectField::__construct(): MultiSelectField only supports many-to-many relations');
     }
     parent::__construct($name, $title, $dataSource, '', null, true);
 }
开发者ID:helpfulrobot,项目名称:fullscreeninteractive-silverstripe-multiselectfield,代码行数:57,代码来源:MultiSelectField.php

示例2: removeEmptyAttributes

 /**
  * Remove pages with empty attributes
  *
  * @param SS_List $list
  * @param string $type
  * @return SS_List
  */
 private function removeEmptyAttributes(SS_List $list, $type)
 {
     $pageAttributes = $list->map('ID', $type)->toArray();
     $emptyAttributess = array_map(function ($value) {
         return $value == '';
     }, $pageAttributes);
     if (!count($emptyAttributess)) {
         return $list;
     }
     return $list->filter(array('ID:not' => array_keys(array_filter($emptyAttributess, function ($value) {
         return $value == 1;
     }))));
 }
开发者ID:helpfulrobot,项目名称:littlegiant-silverstripe-seo-editor,代码行数:20,代码来源:SEOEditorAdmin.php

示例3: map

 public function map($index = 'ID', $titleField = 'Title', $emptyString = null, $sort = false)
 {
     return $this->list->map($index, $titleField, $emptyString, $sort);
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:4,代码来源:ListDecorator.php


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