Loads/fills a collection of empty (unloaded) models with data from the persistence layer.

@param   Collections\AbstractCollection  $collection
@return  Model[]
162764
public function loadCollection(Collections\AbstractCollection $collection)
    {
        $identifiers = $collection->getIdentifiers();
        if (empty($identifiers)) {
            // Nothing to query.
            return [];
        }
        if ($collection instanceof Collections\InverseCollection) {
            $recordSet = $this->retrieveInverseRecords($collection->getOwner()->getType(), $collection->getType(), $collection->getIdentifiers(), $collection->getQueryField());
        } else {
            $recordSet = $this->retrieveRecords($collection->getType(), $collection->getIdentifiers());
        }

        $models = [];
        foreach ($recordSet as $record) {
            if (true === $this->cache->has($record['type'], $record['identifier'])) {
                $models[] = $this->cache->get($record['type'], $record['identifier']);
                continue;
            }
            $models[] = $this->loadModel($collection->getType(), $record);
        }
        return $models;
    }
691488
public static function collapseSerialized(EloquentCollection $collection)
	{
		return $collection->map(
			function (SerializedModel $menu_item) {
				return $menu_item->serialized();
			}
		)->collapse();
	}
166227
public function loadCollection(PersistentCollection $collection)
    {
        $association = $collection->getMapping();
        $persister   = $this->getEntityPersister($association->getTargetEntity());

        if ($association instanceof OneToManyAssociationMetadata) {
            $persister->loadOneToManyCollection($association, $collection->getOwner(), $collection);
        } else {
            $persister->loadManyToManyCollection($association, $collection->getOwner(), $collection);
        }

        $collection->setInitialized(true);
    }
561338
public function filterModelCollectionAsContainer(Collection $collection)
    {
        parent::filterModelCollectionAsContainer($collection);

        $collection->filter(new Equals("Accepted", false));
    }
617094
public function intersect($collection)
    {
        $intersection = new DefaultCollection();
        /** @var ModelInterface $localModel */
        foreach ($this as $localModel) {
            /** @var ModelInterface $otherModel */
            foreach ($collection as $otherModel) {
                if (($localModel->getProviderName() === $otherModel->getProviderName())
                    && ($localModel->getId() === $otherModel->getId())
                ) {
                    $intersection->push($localModel);
                }
            }
        }

        return $intersection;
    }
752825
public function loadCollection(PersistentCollectionInterface $collection) : void
    {
        if ($collection->getOwner() === null) {
            throw PersistentCollectionException::ownerRequiredToLoadCollection();
        }

        $this->getDocumentPersister(get_class($collection->getOwner()))->loadCollection($collection);
        $this->lifecycleEventManager->postCollectionLoad($collection);
    }
555720
public function setCollection($collection)
    {
        if (!$this->loaded) {
            $this->load();
        }

        $this->collectionInfo->setCollection($collection);
        return $this;
    }
74071
public function addCollection(RequirementCollection $collection)
    {
        $this->requirements = array_merge($this->requirements, $collection->all());
    }
100963
public function load($collection = null)
    {

        $items = array();

        $list = DB::table($this->table);

        if ($collection !== null) {
            $list = $list->where('key', 'LIKE', $collection . '%');
        }

        $list = $list->pluck('value', 'key');


        // convert dotted list back to multidimensional array
        foreach ($list as $key => $value) {
            $value = json_decode($value);
            array_set($items, $key, $value);
        }

        return $items;
    }
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];
    }
335547
public function collection(Collection $collection)
    {
        $entries = new Entries();

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

            $entry
                ->conditionalField('id', function () {
                    return Subbly::api('subbly.user')->hasAccess('subbly.backend.auth');
                })

                ->field('position')
                ->field('name')
                ->field('description')
                ->field('sku')
                ->field('status')
                ->field('price')
                ->field('sale_price')
                ->field('quantity')

                ->relationshipField('images', 'Subbly\\Presenter\\V1\\ProductImagePresenter')
                ->relationshipField('options', 'Subbly\\Presenter\\V1\\ProductOptionPresenter')
                ->relationshipField('categories', 'Subbly\\Presenter\\V1\\ProductCategoryPresenter')

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

            $entries->addEntry($entry);
        }

        return $entries->toArray();
    }
224449
protected function postCollectionModifiers(Collection $collection)
    {
        if ($this->getOrderByField() && $this->getOrderByDirection()) {
            $field = $this->getOrderByField();
            $desc  = false;

            if ($this->getOrderByDirection() === 'desc') {
                $desc = true;
            }

            $sorted = $collection->sortBy(function ($entry) use ($field) {
                if (property_exists($entry, $field)) {
                    return $entry->{$field};
                }
            }, SORT_NATURAL, $desc);

            return $sorted;
        }

        return $collection;
    }
495194
public function onPreHandleRequestWithCollection(Collection $collection) {
        $output = new ArrayCollection();
        foreach ($collection as $current) {
            $output->add($current);
        }
        return $output;
    }
25733
public function createEmptyCollectionJob(\collection $collection)
    {
        $job = new EmptyCollectionJob($this->translator);
        $settings = simplexml_load_string($job->getEditor()->getDefaultSettings());
        $settings->bas_id = $collection->get_base_id();

        $task = new Task();
        $task->setName($job->getName())
            ->setJobId($job->getJobId())
            ->setSettings($settings->asXML())
            ->setPeriod($job->getEditor()->getDefaultPeriod());

        $this->om->persist($task);
        $this->om->flush();

        $this->notify(NotifierInterface::MESSAGE_CREATE);

        return $task;
    }
160331
public function load($collection)
    {
        $collectionId = $this->getCollectionId($collection);

        if ($this->isValidCollectionId($collectionId)) {
            throw new ClientException('Cannot alter a collection without a collection id');
        }

        $result = $this->getConnection()->put(
            UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collectionId, self::OPTION_LOAD]),
            ''
        );

        return $result;
    }
915421
public function getCollection($collectionClass = CreateFromAttributesInterface::class)
    {
        $collection = [];
        if ($this->isSuccessful()) {
            $data = $this->getData();
            foreach ($data as $attributes) {
                /** @var AbstractModel $collectionClass */
                $collection[] = $collectionClass::createFromAttributes($attributes);
            }
        }

        return $collection;
    }
524417
protected function requestLogs(RequestLogCollection $collection)
    {
        $requests        = [
            'total' => $collection->count(),
        ];
        $size            = 0;
        $requestsCount   = 0;
        $lastCreatedDate = 0;
        $lastUpdatedDate = 0;
        foreach ($collection as $model) {
            $size          += $model->file()->getSize();
            $requestsCount += $model->entries()->count();
            $createdAt     = $model->createdAt()->toDateTimeString();
            if ($lastCreatedDate < $createdAt) {
                $lastCreatedDate = $createdAt;
            }
            $updatedAt = $model->updatedAt()->toDateTimeString();
            if ($lastUpdatedDate < $updatedAt) {
                $lastUpdatedDate = $updatedAt;
            }
        }
        return $requests += [
            'size'              => $size,
            'requests_count'    => $requestsCount,
            'last_created_date' => $lastCreatedDate,
            'last_updated_date' => $lastUpdatedDate
        ];
    }