Определяет используемые для коллекций соединения с БД
@param IHierarchicCollection[] $collections
@return Connection[]
351834
protected function detectUsedDriversByCollections(array $collections)
    {
        $drivers = [];

        foreach ($collections as $collection) {
            $source = $collection
                ->getMetadata()
                ->getCollectionDataSource();
            $drivers[$source->getMasterServerId()] = $source
                ->getMasterServer()
                ->getConnection();
        }

        return $drivers;
    }
877167
public function transform($collection)
    {
        if (null === $collection) {
            return [];
        }

        if (!$collection instanceof Collection) {
            throw new TransformationFailedException('Expected a ' . Collection::class . ' object.');
        }

        $values = [];
        foreach ($collection as $fieldValue) {
            $values[$fieldValue->getField()->getId()] = $fieldValue;
        }

        return $values;
    }
1042477
public function all(array $collections = [], $groupByCollection = false)
    {
        if (count($collections) === 0) {
            if ($groupByCollection === false) {
                return $this->items;
            }

            return $this->itemCollections;
        }

        $result = [];

        foreach ($collections as $collection) {
            if (isset($this->itemCollections[$collection]) === false) {
                continue;
            }

            if ($groupByCollection === false) {
                $result = array_merge($result, $this->itemCollections[$collection]);

                continue;
            }

            $result[$collection] = $this->itemCollections[$collection];
        }

        return $result;
    }
427115
protected function copyCollectionWith(Collection $collection, array $values)
    {
        $collection = clone $collection;

        $collection->exchangeArray($values);

        return $collection;
    }
487033
public function getCollectionRunner(Collection $collection, int $flags = 0): CollectionRunnerInterface
    {
        $collectionQuery = $collection->getQuery();

        if ($collectionQuery instanceof Query) {
            $queryRunner = $this->getQueryRunner($collectionQuery, $flags);

            return new DynamicCollectionRunner($queryRunner, $this->visibilityResolver);
        }

        return new ManualCollectionRunner($this->visibilityResolver);
    }
1240916
public function keys($collection=null) {
    list($collection) = self::_wrapArgs(func_get_args(), 1);
    
    if(!is_object($collection) && !is_array($collection)) throw new Exception('Invalid object');
    
    return self::_wrap(array_keys((array) $collection));
  }
1139750
public function getFetchRelationships($andRelationshipEntities = false)
    {
        $rels = [];
        foreach ($this->relationships as $relationship) {
            if ($relationship->isFetch() && !$relationship->isRelationshipEntity()) {
                $rels[] = $relationship;
            }
        }

        return $rels;
    }
1322887
public function hydrateCollection(array $collection)
    {
        $records = array();

        foreach ($collection as $key => $record) {
            if ($record instanceof \stdClass) {
                $records[$key] = $this->hydrate($record);
            } else {
                $records[$key] = $this->hydrateRid(new Rid($record));
            }
        }

        return new ArrayCollection($records);
    }
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;
    }
279286
public function select(array $connections): array
    {
        $allNum = count($connections);

        if ($this->pointer >= $allNum || $allNum === 1) {
            $this->pointer = 0;
        }

        return $connections[$this->pointer];
    }
696656
protected static function getClassFromCollection( array $collection )
    {
        // Make sure everything in this container is of __exactly__ the same type.
        // This is a stronger check than the entity container performs (child entities are ok in the container)
        $classes = array_unique( array_map( 'get_class', $collection ) );

        if( count( $classes ) > 1 ) {
            // TODO this could fallback to persisting every entity individually. That would work.
            throw new \Exception(
                sprintf(
                    "Can't manage entities in a container with multiple types, these are %s.",
                    implode( ", ", $classes )
                )
            );
        }
        return array_pop( $classes );

    }
1052666
function giveCollection(MongoDB\Collection $collection)
    {
        if ($this->collection)
            throw new exImmutable;


        $this->collection = $collection;
        return $this;
    }
1025917
public function merge(CollectionInterface $collection)
    {
        $this->items = array_merge(
            $this->getItems(),
            $collection->getItems()
        );

        return $this;
    }
207403
public function getTree(\Illuminate\Database\Eloquent\Collection $collection)
    {
        $collection = $collection->sortBy($this->repository->getOrderField());

        return $collection;
    }
1200784
public static function toList($collection) {
		$list = new ArrayList();
		foreach ($collection as $v) {
			$list->add(self::toCollection($v));
		}
		return $list;
	}
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);
    }
552931
private function getObjectClass(ICollection $collection, IObjectType $objectType)
    {
        if (null != ($objectClass = $objectType->getObjectClass())) {
            return $objectClass;
        } elseif ($collection instanceof IHierarchicCollection || $collection instanceof ICommonHierarchy) {
            return $this->defaultHierarchicObjectClass;
        } else {
            return $this->defaultObjectClass;
        }
    }