Create a clone of this collection, and all its versions, contents and attributes.

@return \Concrete\Core\Page\Collection\Collection
167315
public function duplicateCollection()
    {
        $app = Application::getFacadeApplication();
        $cloner = $app->make(Cloner::class);
        $clonerOptions = $app->build(ClonerOptions::class)->setKeepOriginalAuthor(true);
        $newCollection = $cloner->cloneCollection($this, $clonerOptions);

        return $newCollection;
    }
598932
public function copy()
	{
		$view = $this->getView();

		$view->attributeData = $this->toArray( $view->item, true );
		$view->attributeBody = '';

		foreach( $this->getSubClients() as $client ) {
			$view->attributeBody .= $client->copy();
		}

		return $this->render( $view );
	}
52281
public function createClone(Page $originPage = null)
    {
        $class = ClassUtils::getRealClass($this);
        $clone = new $class(null, null);
        $clone->_accept = self::getShortClassname($this->_accept);
        $clone->_maxentry = $this->_maxentry;
        $clone->_minentry = $this->_minentry;
        $clone->_parameters = $this->_parameters;
        $clone->_mainnode = $this->_mainnode;

        if (
            null !== $originPage
            && is_array($originPage->cloningData)
            && array_key_exists('contents', $originPage->cloningData)
        ) {
            $originPage->cloningData['contents'][$this->getUid()] = $clone;
        }

        if (!($this instanceof ContentSet)) {
            foreach ($this->_data as $key => $values) {
                foreach ($values as $type => &$value) {
                    if (is_array($value)) {
                        $keys = array_keys($value);
                        $values = array_values($value);

                        $type = end($keys);
                        $value = end($values);
                    }

                    if ('scalar' === $type) {
                        $decode = json_decode($value, true);
                        $clone->$key = (JSON_ERROR_NONE === json_last_error()) ? ((null === $decode) ? $value : $decode) : $value;
                    } elseif ('array' !== $type) {
                        foreach ($this->_subcontent as $subcontent) {
                            if ($subcontent->getUid() == $value) {
                                $newsubcontent = $subcontent->createClone($originPage);
                                $clone->$key = $newsubcontent;
                                break;
                            }
                        }
                    } else {
                        $clone->$key = $value;
                    }
                }
                unset($value);
            }
        }

        return $clone;
    }
563782
public function build()
	{
		$listMapper = $this->getMapper();

		$model      = $this->getModel();
		$items      = $model::with([]);
		$primaryKey = (new $model)->getKeyName();

		// Field ordering
		if (Input::has('_order_by')) {
			$items->orderBy(Input::get('_order_by'), Input::get('_order'));
		}

		// Field filters
		foreach (Input::all() as $key => $value) {
			if (empty($value) || substr($key, 0, 1) == '_' || $key == 'page') {
				continue;
			}

			$items->where($key, 'LIKE', '%' . $value . '%');
		}

		// Result scopes
		if (Input::has('_scope')) {
			$items->{Input::get('_scope')}();
		}

		$items = $items->paginate($listMapper->getAdmin()->getPerPage());
		$this->setPaginator($items);

		$result = [];
		foreach ($items as $item) {
			$row = new ListResult;
			$row->setIdentifier($item->{$primaryKey});

			foreach ($listMapper->getFields() as $field) {
				$clone = clone $field;
				$name  = $clone->getName();
				$value = $item->{$name};

				if ($clone->hasBefore()) {
					$before = $clone->getBefore();
					$value  = $before($value);
				}

				if ($clone->isMultiple()) {
					$value = Value::decode(Config::get('bauhaus::admin.multiple-serializer'), $value);
					$value = implode(', ', $value);
				}

				$clone
					->setContext(BaseField::CONTEXT_LIST)
					->setRowId($item->{$primaryKey})
					->setValue($value);

				$row->addField($name, $clone);
			}

			$result[] = $row;
		}

		$this->setResult($result);
	}
867753
public function CloneInstance()
	{
		/**
		 * @var BufferedNodeIterator $res
		 */
		$clone = new BufferedNodeIterator();
		$clone->src = $this->src->CloneInstance();
		$clone->buffer = $this->buffer;
		$clone->empty = $this->empty;
		$clone->filled = $this->filled;
		return $clone;
	}
371252
public function create(): ResourceNameCollection
    {
        $classes = [];
        if ($this->decorated) {
            foreach ($this->decorated->create() as $resourceClass) {
                $classes[$resourceClass] = true;
            }
        }

        foreach ($this->extractor->getResources() as $resourceClass => $resource) {
            $classes[$resourceClass] = true;
        }

        return new ResourceNameCollection(array_keys($classes));
    }
200740
private function generate() : Collection
    {
        if (! $this->cache) {
            $this->cache = $this->components
                ->map(function ($classes, $name) {
                    return (new ComponentStatistics($name, $classes))->toArray();
                })
                ->sortBy(function ($component, $_) {
                    return Str::contains($component['component'], 'Test') ? 1 : $component['component'];
                });
        }

        return $this->cache;
    }
592049
function copy() {
		$new_object = new static();
		$values = $this->toArray();

		foreach (static::$_primaryKeys as $pk) {
			unset($values[$pk]);
		}

		$new_object->fromArray($values);
		return $new_object;
	}
443124
public function copy()
    {
        $list = [];
        foreach ($this->getIterator() as $key => $value) {
            $list[$key] = \is_object($value) ? clone $value : $value;
        }

        return $this->createFrom($list);
    }
1322622
public function copy()
	{
		$view = $this->getView();

		$view->suggestData = $this->toArray( $view->item, true );
		$view->suggestBody = '';

		foreach( $this->getSubClients() as $client ) {
			$view->suggestBody .= $client->copy();
		}

		return $this->render( $view );
	}
449431
public function getVersionToModify()
    {
        $u = new User();
        $vObj = $this->getVersionObject();
        if ($this->isMasterCollection() || ($vObj->isNew())) {
            return $this;
        } else {
            $nc = $this->cloneVersion(null);

            return $nc;
        }
    }
136187
public function copy()
	{
		$view = $this->getView();

		$view->hiddenData = $this->toArray( $view->item, true );
		$view->hiddenBody = '';

		foreach( $this->getSubClients() as $client ) {
			$view->hiddenBody .= $client->copy();
		}

		return $this->render( $view );
	}
555167
protected function getContent()
    {
        $content = $this->session->has($this->instance)
            ? $this->session->get($this->instance)
            : new Collection;

        return $content;
    }
1114564
public function make_clone() {
        global $DB, $USER, $PAGE;

        $fordb = new stdClass();
        foreach (get_object_vars($this) as $k => $v) {
            $fordb->{$k} = $v;
        }

        $fordb->name = get_string('copyof', 'badges', $this->name);
        $fordb->status = BADGE_STATUS_INACTIVE;
        $fordb->usercreated = $USER->id;
        $fordb->usermodified = $USER->id;
        $fordb->timecreated = time();
        $fordb->timemodified = time();
        unset($fordb->id);

        if ($fordb->notification > 1) {
            $fordb->nextcron = badges_calculate_message_schedule($fordb->notification);
        }

        $criteria = $fordb->criteria;
        unset($fordb->criteria);

        if ($new = $DB->insert_record('badge', $fordb, true)) {
            $newbadge = new badge($new);

            // Copy badge image.
            $fs = get_file_storage();
            if ($file = $fs->get_file($this->get_context()->id, 'badges', 'badgeimage', $this->id, '/', 'f1.png')) {
                if ($imagefile = $file->copy_content_to_temp()) {
                    badges_process_badge_image($newbadge, $imagefile);
                }
            }

            // Copy badge criteria.
            foreach ($this->criteria as $crit) {
                $crit->make_clone($new);
            }

            // Copy endorsement.
            $endorsement = $this->get_endorsement();
            if ($endorsement) {
                unset($endorsement->id);
                $endorsement->badgeid = $new;
                $newbadge->save_endorsement($endorsement);
            }

            // Copy alignments.
            $alignments = $this->get_alignments();
            foreach ($alignments as $alignment) {
                unset($alignment->id);
                $alignment->badgeid = $new;
                $newbadge->save_alignment($alignment);
            }

            // Copy related badges.
            $related = $this->get_related_badges(true);
            if (!empty($related)) {
                $newbadge->add_related_badges(array_keys($related));
            }

            // Trigger event, badge duplicated.
            $eventparams = array('objectid' => $new, 'context' => $PAGE->context);
            $event = \core\event\badge_duplicated::create($eventparams);
            $event->trigger();

            return $new;
        } else {
            throw new moodle_exception('error:clone', 'badges');
            return false;
        }
    }
1222894
public function create()
    {
        $instance = self::createWishList($this);
        $this->setId($instance->getId());
        return $instance;
    }
1207711
public function files()
    {
        $filesList = array_filter($this->items, function($item) {
            return ($item['instance'] instanceof FileInterface);
        });

        $filesList = array_map(function($item) {
            return $item['instance'];
        }, $filesList);

        return new Collection($filesList);
    }
766553
public function getIterator()
    {
    	if ($this->sortedIterator === null) {
    	    if ($this->cloneItems) {
    	        $array = array();
                foreach ($this->originalIterator as $key => $value) {
                    $array[$key] = clone $value;
                }
            } else {
    	        $array = iterator_to_array($this->originalIterator);
    	    }
    	    $this->sort($array);
    	    $this->sortedIterator = new \ArrayIterator($array);
    	}
    	return $this->sortedIterator;
    }