Set the collection

@param   string          $collection     Name of the collection
@return  ClassMetadata
555720
public function setCollection($collection)
    {
        if (!$this->loaded) {
            $this->load();
        }

        $this->collectionInfo->setCollection($collection);
        return $this;
    }
521879
public void setCollection(String collection) {
        addField(ConfigureNodeFields.collection, FormField.Type.text_single);
        setAnswer(ConfigureNodeFields.collection.getFieldName(), collection);
    }
102572
public static function fromCollection($collection) {
		if (!(is_array($collection) || $collection instanceof Iterator)) {
			throw new InvalidArgumentException('$collection is neither an array nor an iterator');
		}

		return self::toCollection($collection);
	}
373713
public function setCollections($collections)
    {
        if (!is_array($collections) && !$collections instanceof Traversable) {
            throw new Exception\InvalidArgumentException(sprintf(
                '%s: expects an array or Traversable, received "%s"',
                __METHOD__,
                (is_object($collections) ? get_class($collections) : gettype($collections))
            ));
        }

        if ($collections instanceof Traversable) {
            $collections = ArrayUtils::iteratorToArray($collections);
        }

        $this->collections = $collections;
    }
462025
public function mergeWith(Collection $collection): Collection
    {
        $calledClass = get_called_class();

        if ($collection instanceof $calledClass) {
            foreach ($collection as $key => $object) {
                $this[$key] = $object;
            }
        } else {
            throw new \InvalidArgumentException(sprintf('%s::mergeWith() method require an same type of Collection.', get_class($this)));
        }

        return $this;
    }
724377
public function setMetaData($metaData) {
		if (is_array($metaData) && empty($metaData)) {
			$this->metaData = new \stdClass;
		} else {
			$this->metaData = $metaData;
		}

		return $this;
	}
818961
protected function transformCollection(array $collection, string $class) : Collection
    {
        return collect($collection)->map(function ($attributes) use ($class) {
            return $this->transformItem($attributes, $class);
        });
    }
686630
public static function get_metadata(collection $collection) : collection {
        $collection->add_external_location_link(
            'flickr.com',
            [
                'text' => 'privacy:metadata:repository_flickr:text'
            ],
            'privacy:metadata:repository_flickr'
        );

        // Flickr preferences.
        $collection->add_user_preference(
            'repository_flickr_access_token',
            'privacy:metadata:repository_flickr:preference:repository_flickr_access_token'
        );
        $collection->add_user_preference(
            'repository_flickr_access_token_secret',
            'privacy:metadata:repository_flickr:preference:repository_flickr_access_token_secret'
        );

        return $collection;
    }
32156
public static function get_metadata(collection $collection) : collection {
        $collection->add_database_table('course_completions', [
                'userid' => 'privacy:metadata:userid',
                'course' => 'privacy:metadata:course',
                'timeenrolled' => 'privacy:metadata:timeenrolled',
                'timestarted' => 'privacy:metadata:timestarted',
                'timecompleted' => 'privacy:metadata:timecompleted',
                'reaggregate' => 'privacy:metadata:reaggregate'
            ], 'privacy:metadata:coursesummary');
        $collection->add_database_table('course_modules_completion', [
                'userid' => 'privacy:metadata:userid',
                'coursemoduleid' => 'privacy:metadata:coursemoduleid',
                'completionstate' => 'privacy:metadata:completionstate',
                'viewed' => 'privacy:metadata:viewed',
                'overrideby' => 'privacy:metadata:overrideby',
                'timemodified' => 'privacy:metadata:timemodified'
            ], 'privacy:metadata:coursemodulesummary');
        $collection->add_database_table('course_completion_crit_compl', [
                'userid' => 'privacy:metadata:userid',
                'course' => 'privacy:metadata:course',
                'gradefinal' => 'privacy:metadata:gradefinal',
                'unenroled' => 'privacy:metadata:unenroled',
                'timecompleted' => 'privacy:metadata:timecompleted'
            ], 'privacy:metadata:coursecompletedsummary');
        return $collection;
    }
289629
public function setCollection($collection)
    {
        $this->indexedContainer = $collection;

        foreach ($collection as $argModel) {
            $this->hashedContainer[$argModel->getName()] = $argModel;
        }

        return $this;
    }
975706
public function setCollectionConfig($config)
    {
        if (empty($config) || !is_array($config)) {
            $config = [];
        }

        $this->collectionConfig = array_replace_recursive(
            $this->defaultCollectionConfig(),
            $this->parseCollectionConfig($config)
        );

        return $this;
    }
190821
public function updateMany(): Collection
	{
		$collection = new Collection();

		foreach ($this->getInput() as $item) {
			$repository = clone $this;
			$repository->setInput($item);
			$collection->add($repository->update($repository->getInputId()));
		}

		return $collection;
	}
157791
public function setMongaCollection($collection_name)
    {
        $this->collection = $this->database->collection($collection_name);
        return $this->collection;
    }
500720
public function setTranslations(Collection $collection)
    {
        $this->translations = new ArrayCollection();

        foreach ($collection as $translation) {
            $this->addTranslation($translation);
        }
    }
975508
public static function get_metadata(collection $collection) : collection {
        // These tables are really data about site configuration and not user data.

        // The config_log includes information about which user performed a configuration change.
        // The value and oldvalue may contain sensitive information such as accounts for service passwords..
        // This is not considered to be user data.
        $collection->add_database_table('config_log', [
                'userid'        => 'privacy:metadata:config_log:userid',
                'timemodified'  => 'privacy:metadata:config_log:timemodified',
                'plugin'        => 'privacy:metadata:config_log:plugin',
                'name'          => 'privacy:metadata:config_log:name',
                'value'         => 'privacy:metadata:config_log:value',
                'oldvalue'      => 'privacy:metadata:config_log:oldvalue',
            ], 'privacy:metadata:config_log');

        // The upgrade_log includes information about which user performed an upgrade.
        // This is not considered to be user data.
        $collection->add_database_table('upgrade_log', [
                'type'          => 'privacy:metadata:upgrade_log:type',
                'plugin'        => 'privacy:metadata:upgrade_log:plugin',
                'version'       => 'privacy:metadata:upgrade_log:version',
                'targetversion' => 'privacy:metadata:upgrade_log:targetversion',
                'info'          => 'privacy:metadata:upgrade_log:info',
                'details'       => 'privacy:metadata:upgrade_log:details',
                'backtrace'     => 'privacy:metadata:upgrade_log:backtrace',
                'userid'        => 'privacy:metadata:upgrade_log:userid',
                'timemodified'  => 'privacy:metadata:upgrade_log:timemodified',
            ], 'privacy:metadata:upgrade_log');

        // The task_adhoc includes information about pending adhoc tasks, some of which may be run as a user.
        // These are removed as the task completes.
        $collection->add_database_table('task_adhoc', [
                'component'     => 'privacy:metadata:task_adhoc:component',
                'nextruntime'   => 'privacy:metadata:task_adhoc:nextruntime',
                'userid'        => 'privacy:metadata:task_adhoc:userid',
            ], 'privacy:metadata:task_adhoc');

        // The task_log table stores debugging data for tasks.
        // These are cleaned regularly and intended purely for debugging.
        $collection->add_database_table('task_log', [
                'component'     => 'privacy:metadata:task_log:component',
                'userid'        => 'privacy:metadata:task_log:userid',
            ], 'privacy:metadata:task_log');

        // The events_queue includes information about pending events tasks.
        // These are stored for short periods whilst being processed into other locations.
        $collection->add_database_table('events_queue', [
                'eventdata'     => 'privacy:metadata:events_queue:eventdata',
                'stackdump'     => 'privacy:metadata:events_queue:stackdump',
                'userid'        => 'privacy:metadata:events_queue:userid',
                'timecreated'   => 'privacy:metadata:events_queue:timecreated',
            ], 'privacy:metadata:events_queue');

        // The log table is defined in core but used in logstore_legacy.
        $collection->add_database_table('log', [
            'time' => 'privacy:metadata:log:time',
            'userid' => 'privacy:metadata:log:userid',
            'ip' => 'privacy:metadata:log:ip',
            'action' => 'privacy:metadata:log:action',
            'url' => 'privacy:metadata:log:url',
            'info' => 'privacy:metadata:log:info'
        ], 'privacy:metadata:log');

        return $collection;
    }
301619
public function reload($collection = null)
    {
        if ($collection === null) {
            $collection = $this->getCore();
        }

        return $this->collections()->reload($collection);
    }
695100
public static function get_metadata(collection $collection) : collection {
        $statsuserdaily = [
            'courseid' => 'privacy:metadata:courseid',
            'userid' => 'privacy:metadata:userid',
            'roleid' => 'privacy:metadata:roleid',
            'timeend' => 'privacy:metadata:timeend',
            'statsreads' => 'privacy:metadata:statsreads',
            'statswrites' => 'privacy:metadata:statswrites',
            'stattype' => 'privacy:metadata:stattype'
        ];

        $statsuserweekly = [
            'courseid' => 'privacy:metadata:courseid',
            'userid' => 'privacy:metadata:userid',
            'roleid' => 'privacy:metadata:roleid',
            'timeend' => 'privacy:metadata:timeend',
            'statsreads' => 'privacy:metadata:statsreads',
            'statswrites' => 'privacy:metadata:statswrites',
            'stattype' => 'privacy:metadata:stattype'
        ];

        $statsusermonthly = [
            'courseid' => 'privacy:metadata:courseid',
            'userid' => 'privacy:metadata:userid',
            'roleid' => 'privacy:metadata:roleid',
            'timeend' => 'privacy:metadata:timeend',
            'statsreads' => 'privacy:metadata:statsreads',
            'statswrites' => 'privacy:metadata:statswrites',
            'stattype' => 'privacy:metadata:stattype'
        ];
        $collection->add_database_table('stats_user_daily', $statsuserdaily, 'privacy:metadata:statssummary');
        $collection->add_database_table('stats_user_weekly', $statsuserweekly, 'privacy:metadata:statssummary');
        $collection->add_database_table('stats_user_monthly', $statsusermonthly, 'privacy:metadata:statssummary');
        return $collection;
    }