Load a collection into the server's memory

This will load the given collection into the server's memory.

@throws Exception

@param mixed $collection - collection id as string or number or collection object

@return HttpResponse - HTTP response object
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;
    }
1118053
public function getCursor($collection = "")
		{
			if (empty($collection)) {
				throw new Exception("In order to retrieve documents from MongoDB you must provide a collection name.");
			}

			$documents = $this->db->{$collection}
			->find($this->wheres, $this->selects)
			->limit((int) $this->limit)
			->skip((int) $this->offset)
			->sort($this->sorts);

			$this->_clear();

			return $documents;
		}
348378
private function _collection($collection) {
    return (!is_array($collection) && !is_object($collection)) ? str_split((string) $collection) : $collection;
  }
1347327
private function loadReferenceManyCollectionInverseSide(PersistentCollectionInterface $collection)
    {
        $query     = $this->createReferenceInverseSideQuery($collection->getMapping(), $collection->getOwner());
        $documents = $query->execute()->toArray();

        foreach ($documents as $key => $document) {
            $collection->add($document);
        }
    }
289629
public function setCollection($collection)
    {
        $this->indexedContainer = $collection;

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

        return $this;
    }
608122
public function load( $q = null, $collection = false )
	{
		$alias = $this->getAlias();
		$array = $this->loadArray( $q, $collection );
		$t = $this;
		$ret = array_map_val( $array[$alias], function()use($t)
		{
			$row = func_get_arg(0);
			$obj = $t->modelFactory( $row );
			$obj->changedColumnsReset();
			return $obj;
		} );
		return $ret;
	}
104720
private function initCollection(string $collection, string $class = null): void
    {
        $this->$collection = new Collection();
        $this->$collection->macroObject('createItem',
            function () use ($class): ?Assignable {
                if (null === $class) {
                    return null;
                }
                if (!class_exists($class)) {
                    throw new InvalidArgumentException(sprintf('Can not load class: %s', $class));
                }
                $item = new $class;
                if (!$item instanceof Assignable) {
                    throw new InvalidArgumentException(sprintf('%s must implement Assignable', $class));
                }

                return $item;
            });
    }
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));
  }
374137
private function loadReferenceManyWithRepositoryMethod(PersistentCollectionInterface $collection)
    {
        $iterator  = $this->createReferenceManyWithRepositoryMethodIterator($collection);
        $mapping   = $collection->getMapping();
        $documents = $iterator->toArray();
        foreach ($documents as $key => $obj) {
            if ($mapping->type === Type::MAP) {
                $collection->set($key, $obj);
            } else {
                $collection->add($obj);
            }
        }
    }
1285994
public function materializeCollection($collection)
    {
        $materializedCollection = new Collection();
        foreach ($collection as $resource) {
            $materializedCollection->add($this->materialize($resource));
        }
        return $materializedCollection;
    }
1174114
private function load()
    {
        if (null === $this->collection) {
            $this->collection = $this->transformer->getChildren($this->page);
        }
    }
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;
    }
671107
public static function load($arg)
    {
        if (is_object($arg) && $arg instanceof Entity) {
            $class = get_class($arg);
        } elseif (is_object($arg) && $arg instanceof Collection) {
            $class = $arg->getEntityClass();
        } elseif (is_object($arg) && $arg instanceof Reflection) {

            $class = $arg->getClassName();
            if (!isset(self::$registered[$class])) {
                return self::$registered[$class] = $arg;
            }
            return $arg;
        } elseif (is_string($arg)) {
            $class = $arg;
        } else {
            throw new Exception\InvalidArgumentException(
                "Entity identifier must be object, collection, class or name!",
                $arg
            );
        }

        if (!is_subclass_of($class, "UniMapper\Entity")) {
            $class = Convention::nameToClass($arg, Convention::ENTITY_MASK);
        }

        if (!class_exists($class)) {
            throw new Exception\InvalidArgumentException(
                "Entity class " . $class . " not found!"
            );
        }

        if (isset(self::$registered[$class])) {
            return self::$registered[$class];
        }

        return self::$registered[$class] = new Reflection($class);
    }
53317
protected function collection_query( &$collection ) 
	{
		$local_keys = array();
		
		foreach( $collection as $item )
		{
			$local_keys[] = $item->raw( $this->local_key );
		}
		
		// set the correct collection where
		$this->query->wheres = array();
		$this->query->where( $this->foreign_key, 'in', $local_keys );
		$this->query->group_result( $this->foreign_key );
		
		$this->query->limit( null );
	}
1340582
public function load(): ResponseInterface
    {
        if (false === mb_strpos($this->file, '://')) {
            if (!is_file($this->file)) {
                throw new Exception('The given local file [' . $this->file . '] is not a file', Exception::LOCAL_FILE_NOT_READABLE);
            }

            if (!is_readable($this->file)) {
                throw new Exception('The given local file [' . $this->file . '] is not readable', Exception::LOCAL_FILE_NOT_READABLE);
            }
        }

        $stream = fopen($this->file, 'rb', false);

        if (false === $stream) {
            throw new Exception('could not read content from the given local file  [' . $this->file . ']', Exception::LOCAL_FILE_NOT_READABLE);
        }

        return new Response(200, [], new Stream($stream));
    }
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;
    }
1141014
protected function dispatchCollection($collection)
    {
        // find and send group variables
        $group = isset($collection['group']) ? $collection['group'] : null;
        // dispatch action dispatcher
        $content = $this->getActionDispatcher()->dispatch($collection['action'], $group);
        if (is_string($content)) {
            $this->sendContentString($content, $this->getRequest());
        }
    }