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


PHP ArrayList::merge方法代码示例

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


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

示例1: doAllChildrenIncludingDeleted

 public function doAllChildrenIncludingDeleted($context = null)
 {
     if (!$this->owner) {
         user_error('Hierarchy::doAllChildrenIncludingDeleted() called without $this->owner');
     }
     $baseClass = ClassInfo::baseDataClass($this->owner->class);
     if ($baseClass) {
         $stageChildren = $this->owner->stageChildren(true);
         $stageChildren = $this->RemoveNewsPostsFromSiteTree($stageChildren);
         // Add live site content that doesn't exist on the stage site, if required.
         if ($this->owner->hasExtension('Versioned')) {
             // Next, go through the live children.  Only some of these will be listed
             $liveChildren = $this->owner->liveChildren(true, true);
             if ($liveChildren) {
                 $liveChildren = $this->RemoveNewsPostsFromSiteTree($liveChildren);
                 $merged = new ArrayList();
                 $merged->merge($stageChildren);
                 $merged->merge($liveChildren);
                 $stageChildren = $merged;
             }
         }
         $this->owner->extend("augmentAllChildrenIncludingDeleted", $stageChildren, $context);
     } else {
         user_error("Hierarchy::AllChildren() Couldn't determine base class for '{$this->owner->class}'", E_USER_ERROR);
     }
     return $stageChildren;
 }
开发者ID:silverstripers,项目名称:silverstripe-news,代码行数:27,代码来源:NewsHierarchy.php

示例2: getAllBlocks

 public function getAllBlocks()
 {
     $blocks = new ArrayList();
     $blocks->merge($this->getMyBlocks());
     $blocks->merge($this->getDockedBlocks());
     return $blocks;
 }
开发者ID:salted-herring,项目名称:silverstripe-block,代码行数:7,代码来源:PrintBlocks.php

示例3: getHelpItems

 /**
  * Returns all the {@link InlineHelpTopic}s attached to this page.
  *
  * @return InlineHelpTopic[]
  */
 public function getHelpItems()
 {
     $items = new ArrayList();
     $items->merge(InlineHelpTopic::get()->where('"AttachType" = \'All\''));
     $items->merge(InlineHelpTopic::get()->where(sprintf('"AttachType" = \'Type\' AND "AttachPageType" = \'%s\'', $this->owner->class)));
     $items->merge($this->owner->HelpTopics());
     $stack = $this->owner->parentStack();
     array_shift($stack);
     if ($stack) {
         $items->merge(InlineHelpTopic::get()->where(sprintf('"AttachType" = \'Children\' AND "ParentFilterID" IN(%s)', implode(', ', array_map(create_function('$self', 'return $self->ID;'), $stack)))));
     }
     $items->removeDuplicates();
     return $items;
 }
开发者ID:Neumes,项目名称:silverstripe-inlinehelp,代码行数:19,代码来源:InlineHelpExtension.php

示例4: TalksByMemberID

 function TalksByMemberID($memberID)
 {
     $SpeakerList = new ArrayList();
     // Pull any talks that belong to this Summit and are owned by member
     $talksMemberOwns = $this->Talks("`OwnerID` = " . $memberID . " AND `SummitID` = " . $this->ID);
     $SpeakerList->merge($talksMemberOwns);
     // Now pull any talks that belong to this Summit and the member is listed as a speaker
     $speaker = Speaker::get()->filter('memberID', $memberID)->first();
     if ($speaker) {
         $talksMemberIsASpeaker = $speaker->TalksBySummitID($this->ID);
         // Now merge and de-dupe the lists
         $SpeakerList->merge($talksMemberIsASpeaker);
         $SpeakerList->removeDuplicates('ID');
     }
     return $SpeakerList;
 }
开发者ID:balajijegan,项目名称:openstack-org,代码行数:16,代码来源:Summit.php

示例5: getInheritedSchemas

 /**
  * If this is attached to an object with the hierarchy extension, it returns
  * a set of a schema objects attached to any ancestors (which should be
  * present on this object).
  *
  * @return ArrayList
  */
 public function getInheritedSchemas()
 {
     $result = new ArrayList();
     if (!$this->owner->hasExtension('Hierarchy')) {
         return new ArrayList();
     }
     $ids = array();
     $parents = $this->owner->getAncestors();
     foreach ($parents as $parent) {
         $ids[] = $parent->ID;
     }
     if (count($ids)) {
         $filter = sprintf('"MetadataSchema"."ID" = "MetadataSchemaLink"."SchemaID"' . ' AND "MetadataSchemaLink"."ParentClass" = \'%s\'' . ' AND "MetadataSchemaLink"."ParentID" IN (%s)', ClassInfo::baseDataClass($this->owner->class), implode(', ', $ids));
         $result = MetadataSchema::get()->innerJoin('MetadataSchemaLink', $filter);
         if ($result) {
             $result = new ArrayList($result->toArray());
         } else {
             $result = new ArrayList();
         }
     }
     if ($this->owner instanceof SiteTree) {
         // Check SiteConfig too
         $config = SiteConfig::current_site_config();
         if ($config->hasExtension('MetadataExtension')) {
             $schemas = $config->getAttachedSchemas();
             if ($schemas && $schemas->count()) {
                 $result->merge($schemas);
             }
         }
     }
     return $result;
 }
开发者ID:phill-m,项目名称:silverstripe-metadata,代码行数:39,代码来源:MetadataExtension.php

示例6: searchFromVars

 /**
  * @param string $keywords
  * @param array $filters [optional]
  * @param array $facetSpec [optional]
  * @param int $start [optional]
  * @param int $limit [optional]
  * @param string $sort [optional]
  * @return ArrayData
  */
 function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = '')
 {
     $searchable = ShopSearch::get_searchable_classes();
     $matches = new ArrayList();
     foreach ($searchable as $className) {
         $list = DataObject::get($className);
         // get searchable fields
         $keywordFields = $this->getSearchFields($className);
         // build the filter
         $filter = array();
         // Use parametrized query if SilverStripe >= 3.2
         if (SHOP_SEARCH_IS_SS32) {
             foreach ($keywordFields as $indexFields) {
                 $filter[] = array("MATCH ({$indexFields}) AGAINST (?)" => $keywords);
             }
             $list = $list->whereAny($filter);
         } else {
             foreach ($keywordFields as $indexFields) {
                 $filter[] = sprintf("MATCH ({$indexFields}) AGAINST ('%s')", Convert::raw2sql($keywords));
             }
             // join all the filters with an "OR" statement
             $list = $list->where(implode(' OR ', $filter));
         }
         // add in any other filters
         $list = FacetHelper::inst()->addFiltersToDataList($list, $filters);
         // add any matches to the big list
         $matches->merge($list);
     }
     return new ArrayData(array('Matches' => $matches, 'Facets' => FacetHelper::inst()->buildFacets($matches, $facetSpec, (bool) Config::inst()->get('ShopSearch', 'auto_facet_attributes'))));
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-search,代码行数:39,代码来源:ShopSearchMysql.php

示例7: searchFromVars

 /**
  * @param string $keywords
  * @param array $filters [optional]
  * @param array $facetSpec [optional]
  * @param int $start [optional]
  * @param int $limit [optional]
  * @param string $sort [optional]
  * @return ArrayData
  */
 function searchFromVars($keywords, array $filters = array(), array $facetSpec = array(), $start = -1, $limit = -1, $sort = '')
 {
     $searchable = ShopSearch::get_searchable_classes();
     $matches = new ArrayList();
     foreach ($searchable as $className) {
         $list = DataObject::get($className);
         // get searchable fields
         $keywordFields = $this->scaffoldSearchFields($className);
         // convert that list into something we can pass to Datalist::filter
         $keywordFilter = array();
         if (!empty($keywords)) {
             foreach ($keywordFields as $searchField) {
                 $name = strpos($searchField, ':') !== FALSE ? $searchField : "{$searchField}:PartialMatch";
                 $keywordFilter[$name] = $keywords;
             }
         }
         if (count($keywordFilter) > 0) {
             $list = $list->filterAny($keywordFilter);
         }
         // add in any other filters
         $list = FacetHelper::inst()->addFiltersToDataList($list, $filters);
         // add any matches to the big list
         $matches->merge($list);
     }
     return new ArrayData(array('Matches' => $matches, 'Facets' => FacetHelper::inst()->buildFacets($matches, $facetSpec, (bool) Config::inst()->get('ShopSearch', 'auto_facet_attributes'))));
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-search,代码行数:35,代码来源:ShopSearchSimple.php

示例8: downloads

 /**
  * This may need to be optimised. We'll just have to see how it performs.
  *
  * @param SS_HTTPRequest $req
  * @return array
  */
 public function downloads(SS_HTTPRequest $req)
 {
     $downloads = new ArrayList();
     $member = Member::currentUser();
     if (!$member || !$member->exists()) {
         $this->httpError(401);
     }
     // create a dropdown for sorting
     $sortOptions = Config::inst()->get('DownloadableAccountPageController', 'sort_options');
     if ($sortOptions) {
         $sort = $req->requestVar('sort');
         if (empty($sort)) {
             reset($sortOptions);
             $sort = key($sortOptions);
         }
         $sortControl = new DropdownField('download-sort', 'Sort By:', $sortOptions, $sort);
     } else {
         $sort = 'PurchaseDate';
         $sortControl = '';
     }
     // create a list of downloads
     $orders = $member->getPastOrders();
     if (!empty($orders)) {
         foreach ($orders as $order) {
             if ($order->DownloadsAvailable()) {
                 $downloads->merge($order->getDownloads());
             }
         }
     }
     Requirements::javascript(SHOP_DOWNLOADABLE_FOLDER . '/javascript/AccountPage_downloads.js');
     return array('Title' => 'Digital Purchases', 'Content' => '', 'SortControl' => $sortControl, 'HasDownloads' => $downloads->count() > 0, 'Downloads' => $downloads->sort($sort));
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-downloadable,代码行数:38,代码来源:DownloadableAccountPageController.php

示例9: provideGridListItems

 public function provideGridListItems()
 {
     $results = new \ArrayList();
     /** @var Service $service */
     $service = \Injector::inst()->get('SearchService');
     // check something was passed in 'q' parameter up front to skip processing if we can
     if ($service->constraint(Constraints::FullTextVar)) {
         $searchClasses = $this->config()->get('search_classes') ?: [];
         foreach ($searchClasses as $className) {
             $filter = $service->Filters()->filter($className, Constraints::FullTextVar, \Modular\Search\ModelExtension::SearchIndex);
             if ($filter) {
                 $intermediates = \DataObject::get($className)->filter($filter);
                 /** @var ModelExtension|\DataObject $intermediate */
                 foreach ($intermediates as $intermediate) {
                     if ($intermediate->hasMethod('SearchTargets')) {
                         // merge in what the intermediate object thinks are it's actual targets,
                         // e.g. for a ContentBlock this is the Pages which are related to that block
                         $results->merge($intermediate->SearchTargets());
                     } else {
                         // if no search targets nominated then just add the intermediate as it is the target
                         $results->push($intermediate);
                     }
                 }
             }
         }
     }
     return $results;
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:28,代码来源:FulltextProvider.php

示例10: ExpiredDataObjects

 /**
  * @return ArrayList
  */
 private static function ExpiredDataObjects()
 {
     $data_objects = new ArrayList();
     foreach (AutoArchivableExtension::getExtendedClasses() as $class_name) {
         $data_objects->merge(DataObject::get($class_name)->filter(array('AutoArchiveOn' => true, 'AutoArchiveDate:LessThanOrEqual' => date('Y-m-d'))));
     }
     return $data_objects;
 }
开发者ID:taitava,项目名称:silverstripe-autoarchivable,代码行数:11,代码来源:AutoArchiveTask.php

示例11: getEventList

 public function getEventList($start, $end, $filter = null, $limit = null)
 {
     $eventList = new ArrayList();
     foreach ($this->getAllCalendars() as $calendar) {
         if ($events = $calendar->getStandardEvents($start, $end, $filter)) {
             $eventList->merge($events);
         }
     }
     $eventList = $eventList->sort(array("StartDate" => "ASC", "StartTime" => "ASC"));
     $eventList = $eventList->limit($limit);
     return $eventList;
 }
开发者ID:andrewandante,项目名称:blackdorisrovers,代码行数:12,代码来源:Season.php

示例12: merge_owners

 /**
  * Takes a list of groups and members and return a list of unique member.
  *
  * @param SS_List $groups
  * @param SS_List $members
  *
  * @return ArrayList
  */
 public static function merge_owners(SS_List $groups, SS_List $members)
 {
     $contentReviewOwners = new ArrayList();
     if ($groups->count()) {
         $groupIDs = array();
         foreach ($groups as $group) {
             $familyIDs = $group->collateFamilyIDs();
             if (is_array($familyIDs)) {
                 $groupIDs = array_merge($groupIDs, array_values($familyIDs));
             }
         }
         array_unique($groupIDs);
         if (count($groupIDs)) {
             $groupMembers = DataObject::get("Member")->where("\"Group\".\"ID\" IN (" . implode(",", $groupIDs) . ")")->leftJoin("Group_Members", "\"Member\".\"ID\" = \"Group_Members\".\"MemberID\"")->leftJoin("Group", "\"Group_Members\".\"GroupID\" = \"Group\".\"ID\"");
             $contentReviewOwners->merge($groupMembers);
         }
     }
     $contentReviewOwners->merge($members);
     $contentReviewOwners->removeDuplicates();
     return $contentReviewOwners;
 }
开发者ID:kinglozzer,项目名称:silverstripe-contentreview,代码行数:29,代码来源:SiteTreeContentReview.php

示例13: onAfterInit

 public function onAfterInit()
 {
     if (!Director::isDev()) {
         // Only on live site
         $errorcode = $this->owner->failover->ErrorCode ? $this->owner->failover->ErrorCode : 404;
         $extract = preg_match('/^([a-z0-9\\.\\_\\-\\/]+)/i', $_SERVER['REQUEST_URI'], $rawString);
         if ($errorcode == 404 && $extract) {
             $uri = preg_replace('/\\.(aspx?|html?|php[34]?)$/i', '', $rawString[0]);
             $parts = preg_split('/\\//', $uri, -1, PREG_SPLIT_NO_EMPTY);
             $page_key = array_pop($parts);
             $sounds_like = soundex($page_key);
             // extend ignored classes with child classes
             $ignoreClassNames = array();
             if ($configClasses = Config::inst()->get('Intelligent404', 'intelligent_404_ignored_classes')) {
                 foreach ($configClasses as $class) {
                     $ignoreClassNames = array_merge($ignoreClassNames, array_values(ClassInfo::subclassesFor($class)));
                 }
             }
             // get all pages
             $SiteTree = SiteTree::get()->exclude('ClassName', $ignoreClassNames);
             // Translatable support
             if (class_exists('Translatable')) {
                 $SiteTree = $SiteTree->filter('Locale', Translatable::get_current_locale());
             }
             // Multisites support
             if (class_exists('Multisites')) {
                 $SiteTree = $SiteTree->filter('SiteID', Multisites::inst()->getCurrentSiteId());
             }
             $ExactMatches = new ArrayList();
             $PossibleMatches = new ArrayList();
             foreach ($SiteTree as $page) {
                 if ($page->URLSegment == $page_key) {
                     $ExactMatches->push($page);
                 } elseif ($sounds_like == soundex($page->URLSegment)) {
                     $PossibleMatches->push($page);
                 }
             }
             $ExactCount = $ExactMatches->Count();
             $PossibleCount = $PossibleMatches->Count();
             $redirectOnSingleMatch = Config::inst()->get('Intelligent404', 'redirect_on_single_match');
             if ($ExactCount == 1 && $redirectOnSingleMatch) {
                 return $this->RedirectToPage($ExactMatches->First()->Link());
             } elseif ($ExactCount == 0 && $PossibleCount == 1 && $redirectOnSingleMatch) {
                 return $this->RedirectToPage($PossibleMatches->First()->Link());
             } elseif ($ExactCount > 1 || $PossibleCount > 1 || !$redirectOnSingleMatch) {
                 $ExactMatches->merge($PossibleMatches);
                 $content = $this->owner->customise(array('Pages' => $ExactMatches))->renderWith(array('Intelligent404Options'));
                 $this->owner->Content .= $content;
             }
         }
     }
 }
开发者ID:axllent,项目名称:silverstripe-intelligent-404,代码行数:52,代码来源:Intelligent404.php

示例14: relatedByClassName

 /**
  * Return all the page models related to this tag (there may be multiple Page Classe attached so iterate through them all)
  *
  * @param string|array $matchClassNames and array of classnames, a class name or a pattern as used by fnmatch, eg. '*Page'
  * @return \ArrayList
  */
 public function relatedByClassName($matchClassNames)
 {
     $matchClassNames = is_array($matchClassNames) ? $matchClassNames : [$matchClassNames];
     $pages = new \ArrayList();
     foreach ($this()->config()->get('belongs_many_many') as $relationship => $className) {
         foreach ($matchClassNames as $pattern) {
             if (fnmatch($pattern, $className)) {
                 $pages->merge($this()->{$relationship}());
             }
         }
     }
     return $pages;
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:19,代码来源:ModelTag.php

示例15: sequenceGridListItems

 /**
  * @param \DataList|\ArrayList $items
  * @param                      $filters
  * @param array                $parameters
  */
 public function sequenceGridListItems(&$items, $filters, &$parameters = [])
 {
     $limit = isset($parameters['PageLength']) ? $parameters['PageLength'] : null;
     // filter items for each filter to current page length
     if ($limit) {
         $start = GridList::service()->Filters()->start() ?: 0;
         $out = new \ArrayList();
         $currentFilter = GridList::service()->constraint(Constraints::FilterVar);
         if ($currentFilter && $currentFilter != 'all') {
             if ($filter = GridListFilter::get()->filter(['ModelTag' => $currentFilter])->first()) {
                 $out->merge($items->limit($limit, $start));
             }
         } else {
             foreach ($filters as $filter) {
                 $filtered = new \ArrayList();
                 foreach ($items as $item) {
                     if ($item instanceof Block) {
                         // only push blocks first page
                         if ($start == 0) {
                             $filtered->push($item);
                         }
                     } else {
                         if ($currentFilter == 'all') {
                             $filtered->push($item);
                         } else {
                             if ($item->GridListFilters()->find('ID', $filter->ID)) {
                                 $filtered->push($item);
                             }
                         }
                     }
                 }
                 // merge limited filtered items back in
                 $out->merge($filtered->limit($limit, $start));
             }
         }
         $items = $out;
     }
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-modular,代码行数:43,代码来源:Pagination.php


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