Get formated datas for a collection.

@param \Subbly\Model\Collection $collection

@return \Illuminate\Support\Collection
516939
public function collection(Collection $collection)
    {
        $entries = new Entries();

        foreach ($collection as $product) {
            $entry = new Entry($product);

            $entry
                ->field('id')
                ->field('name')
                ->field('description')
                ->field('sku')
                ->field('status')
                ->field('price')
                ->field('sale_price')
                ->field('quantity')

                ->value('image', $product->product->defaultImage())
                // ->relationshipField('product', 'Subbly\\Presenter\\V1\\ProductPresenter')

                ->dateField('created_at')
                ->dateField('updated_at')
            ;

            $entries->addEntry($entry);
        }

        return $entries->toArray();
    }
348378
private function _collection($collection) {
    return (!is_array($collection) && !is_object($collection)) ? str_split((string) $collection) : $collection;
  }
361640
public function loadCollectionItemsData(Collection $collection): array
    {
        $query = $this->getItemSelectQuery();
        $query->where(
            $query->expr()->eq('collection_id', ':collection_id')
        )
        ->setParameter('collection_id', $collection->id, Type::INTEGER);

        $this->applyStatusCondition($query, $collection->status);

        $query->addOrderBy('position', 'ASC');

        return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
    }
216379
public function getOne($collection = "")
		{
			if (empty($collection)) {
				throw new Exception("In order to retrieve documents from MongoDB you must provide a collection name.");
			}

			$returns = $this->db->{$collection}->findOne($this->wheres, $this->selects);

			$this->_clear();

			return $returns;
		}
516828
public function getCollections()
    {
        if ($this->collections) {
            return $this->collections;
        }

        $collectionMapper = ($this->container->dataMapper)('CollectionMapper');

        return $this->collections = $collectionMapper->find();
    }
1200784
public static function toList($collection) {
		$list = new ArrayList();
		foreach ($collection as $v) {
			$list->add(self::toCollection($v));
		}
		return $list;
	}
1212344
public function toCollection($collection, $resultSetType = null)
    {
        $resultSetType = $resultSetType ?: $this->resultSetType;

        if ($resultSetType && false !== strpos($resultSetType, '\\')) {
            $collection = new $resultSetType($collection);
        } else {
            $collection = new ModelCollection($collection);
        }

        return $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;
    }
529970
public function figures($collection)
    {
        $collection = $this->makeCollection($collection);
        $url        = UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collection, self::OPTION_FIGURES]);
        $response   = $this->getConnection()->get($url);

        $data = $response->getJson();

        return $data[self::OPTION_FIGURES];
    }
550616
public function getDictionary($collection)
	{
		$dictionary = array();

		foreach ($collection as $value)
		{
			$dictionary[$value->getKey()] = $value;
		}

		return $dictionary;
	}
889201
public function format(Collection $record)
    {
        return json_encode($this->prepare($record), ($this->prettyPrint ? JSON_PRETTY_PRINT : 0));
    }
916971
public static function get_metadata(collection $collection) : collection {

        $collection->add_database_table('post', [
            'userid' => 'privacy:metadata:post:userid',
            'subject' => 'privacy:metadata:post:subject',
            'summary' => 'privacy:metadata:post:summary',
            'uniquehash' => 'privacy:metadata:post:uniquehash',
            'publishstate' => 'privacy:metadata:post:publishstate',
            'created' => 'privacy:metadata:post:created',
            'lastmodified' => 'privacy:metadata:post:lastmodified',

            // The following columns are unused:
            // coursemoduleid, courseid, moduleid, groupid, rating, usermodified.
        ], 'privacy:metadata:post');

        $collection->link_subsystem('core_comment', 'privacy:metadata:core_comments');
        $collection->link_subsystem('core_files', 'privacy:metadata:core_files');
        $collection->link_subsystem('core_tag', 'privacy:metadata:core_tag');

        $collection->add_database_table('blog_external', [
            'userid' => 'privacy:metadata:external:userid',
            'name' => 'privacy:metadata:external:name',
            'description' => 'privacy:metadata:external:description',
            'url' => 'privacy:metadata:external:url',
            'filtertags' => 'privacy:metadata:external:filtertags',
            'timemodified' => 'privacy:metadata:external:timemodified',
            'timefetched' => 'privacy:metadata:external:timefetched',
        ], 'privacy:metadata:external');

        // We do not report on blog_association because this is just context-related data.

        return $collection;
    }
666970
public static function get_metadata(collection $collection) : collection {

        // Tables not related to users aside from the editing information.
        $collection->add_database_table('competency', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency');

        $collection->add_database_table('competency_coursecompsetting', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_coursecompsetting');

        $collection->add_database_table('competency_framework', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_framework');

        $collection->add_database_table('competency_coursecomp', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_coursecomp');

        $collection->add_database_table('competency_template', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_template');

        $collection->add_database_table('competency_templatecomp', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_templatecomp');

        $collection->add_database_table('competency_templatecohort', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_templatecohort');

        $collection->add_database_table('competency_relatedcomp', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_relatedcomp');

        $collection->add_database_table('competency_modulecomp', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_modulecomp');

        // Tables containing user data.
        $collection->add_database_table('competency_plan', [
            'name' => 'privacy:metadata:plan:name',
            'description' => 'privacy:metadata:plan:description',
            'userid' => 'privacy:metadata:plan:userid',
            'status' => 'privacy:metadata:plan:status',
            'duedate' => 'privacy:metadata:plan:duedate',
            'reviewerid' => 'privacy:metadata:plan:reviewerid',
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_plan');

        $collection->add_database_table('competency_usercomp', [
            'userid' => 'privacy:metadata:usercomp:userid',
            'status' => 'privacy:metadata:usercomp:status',
            'reviewerid' => 'privacy:metadata:usercomp:reviewerid',
            'proficiency' => 'privacy:metadata:usercomp:proficiency',
            'grade' => 'privacy:metadata:usercomp:grade',
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_usercomp');

        $collection->add_database_table('competency_usercompcourse', [
            'userid' => 'privacy:metadata:usercomp:userid',
            'proficiency' => 'privacy:metadata:usercomp:proficiency',
            'grade' => 'privacy:metadata:usercomp:grade',
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_usercompcourse');

        $collection->add_database_table('competency_usercompplan', [
            'userid' => 'privacy:metadata:usercomp:userid',
            'proficiency' => 'privacy:metadata:usercomp:proficiency',
            'grade' => 'privacy:metadata:usercomp:grade',
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_usercompplan');

        $collection->add_database_table('competency_plancomp', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_plancomp');

        $collection->add_database_table('competency_evidence', [
            'action' => 'privacy:metadata:evidence:action',
            'actionuserid' => 'privacy:metadata:evidence:actionuserid',
            'descidentifier' => 'privacy:metadata:evidence:descidentifier',
            'desccomponent' => 'privacy:metadata:evidence:desccomponent',
            'desca' => 'privacy:metadata:evidence:desca',
            'url' => 'privacy:metadata:evidence:url',
            'grade' => 'privacy:metadata:evidence:grade',
            'note' => 'privacy:metadata:evidence:note',
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_evidence');

        $collection->add_database_table('competency_userevidence', [
            'name' => 'privacy:metadata:userevidence:name',
            'description' => 'privacy:metadata:userevidence:description',
            'url' => 'privacy:metadata:userevidence:url',
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_userevidence');

        $collection->add_database_table('competency_userevidencecomp', [
            'timecreated' => 'privacy:metadata:timecreated',
            'timemodified' => 'privacy:metadata:timemodified',
            'usermodified' => 'privacy:metadata:usermodified',
        ], 'privacy:metadata:competency_userevidencecomp');

        // Comments can be left on learning plans and competencies.
        $collection->link_subsystem('core_comment', 'privacy:metadata:core_comments');

        return $collection;
    }
283386
public static function get_metadata(collection $collection) : collection {
        $completedfields = [
            'userid' => 'privacy:metadata:completed:userid',
            'timemodified' => 'privacy:metadata:completed:timemodified',
            'anonymous_response' => 'privacy:metadata:completed:anonymousresponse',
        ];

        $collection->add_database_table('feedback_completed', $completedfields, 'privacy:metadata:completed');
        $collection->add_database_table('feedback_completedtmp', $completedfields, 'privacy:metadata:completedtmp');

        $valuefields = [
            'value' => 'privacy:metadata:value:value'
        ];

        $collection->add_database_table('feedback_value', $valuefields, 'privacy:metadata:value');
        $collection->add_database_table('feedback_valuetmp', $valuefields, 'privacy:metadata:valuetmp');

        return $collection;
    }
406942
public static function get_metadata(collection $collection) : collection {
        $detail = [
                    'assignment' => 'privacy:metadata:assignmentid',
                    'submission' => 'privacy:metadata:submissionpurpose',
                    'onlinetext' => 'privacy:metadata:textpurpose'
                  ];
        $collection->add_database_table('assignsubmission_onlinetext', $detail, 'privacy:metadata:tablepurpose');
        $collection->link_subsystem('core_files', 'privacy:metadata:filepurpose');
        return $collection;
    }
691959
public function getCollectionId($collection)
    {
        if ($collection instanceof Collection) {
            $collectionId = $collection->getId();

            return $collectionId;
        }

        $collectionId = $collection;

        return $collectionId;
    }
187287
public static function get_metadata(collection $collection) : collection {
        $collection->add_database_table('lesson_attempts', [
            'userid' => 'privacy:metadata:attempts:userid',
            'pageid' => 'privacy:metadata:attempts:pageid',
            'answerid' => 'privacy:metadata:attempts:answerid',
            'retry' => 'privacy:metadata:attempts:retry',
            'correct' => 'privacy:metadata:attempts:correct',
            'useranswer' => 'privacy:metadata:attempts:useranswer',
            'timeseen' => 'privacy:metadata:attempts:timeseen',
        ], 'privacy:metadata:attempts');

        $collection->add_database_table('lesson_grades', [
            'userid' => 'privacy:metadata:grades:userid',
            'grade' => 'privacy:metadata:grades:grade',
            'completed' => 'privacy:metadata:grades:completed',
            // The column late is not used.
        ], 'privacy:metadata:grades');

        $collection->add_database_table('lesson_timer', [
            'userid' => 'privacy:metadata:timer:userid',
            'starttime' => 'privacy:metadata:timer:starttime',
            'lessontime' => 'privacy:metadata:timer:lessontime',
            'completed' => 'privacy:metadata:timer:completed',
            'timemodifiedoffline' => 'privacy:metadata:timer:timemodifiedoffline',
        ], 'privacy:metadata:timer');

        $collection->add_database_table('lesson_branch', [
            'userid' => 'privacy:metadata:branch:userid',
            'pageid' => 'privacy:metadata:branch:pageid',
            'retry' => 'privacy:metadata:branch:retry',
            'flag' => 'privacy:metadata:branch:flag',
            'timeseen' => 'privacy:metadata:branch:timeseen',
            'nextpageid' => 'privacy:metadata:branch:nextpageid',
        ], 'privacy:metadata:branch');

        $collection->add_database_table('lesson_overrides', [
            'userid' => 'privacy:metadata:overrides:userid',
            'available' => 'privacy:metadata:overrides:available',
            'deadline' => 'privacy:metadata:overrides:deadline',
            'timelimit' => 'privacy:metadata:overrides:timelimit',
            'review' => 'privacy:metadata:overrides:review',
            'maxattempts' => 'privacy:metadata:overrides:maxattempts',
            'retake' => 'privacy:metadata:overrides:retake',
            'password' => 'privacy:metadata:overrides:password',
        ], 'privacy:metadata:overrides');

        $collection->add_user_preference('lesson_view', 'privacy:metadata:userpref:lessonview');

        return $collection;
    }