From 5ecf240c266ebfa0d21dcb8e68be8095da175944 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 20 Jan 2017 10:47:24 -0700 Subject: [PATCH] Added new `Collection::merge()` method #1258 --- system/src/Grav/Common/Page/Collection.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php index 53baf620d..f4b302721 100644 --- a/system/src/Grav/Common/Page/Collection.php +++ b/system/src/Grav/Common/Page/Collection.php @@ -74,6 +74,21 @@ class Collection extends Iterator return new static($this->items, $this->params, $this->pages); } + /** + * + * Merge another collection with the current collection + * + * @param Collection $collection + * @return $this + */ + public function merge(Collection $collection) + { + foreach($collection as $page) { + $this->addPage($page); + } + return $this; + } + /** * Set parameters to the Collection *