yii\mongodb\file\StreamWrapper::fetchCollection PHP Method

fetchCollection() private method

Fetches associated file collection from stream options.
private fetchCollection ( ) : Collection
return Collection file collection instance.
    private function fetchCollection()
    {
        $contextOptions = $this->getContextOptions();
        if (isset($contextOptions[$this->protocol]['collection'])) {
            $collection = $contextOptions[$this->protocol]['collection'];
            if ($collection instanceof Collection) {
                throw new InvalidConfigException('"collection" context option should be an instance of "' . Collection::className() . '"');
            }
            return $collection;
        }
        if (isset($contextOptions[$this->protocol]['db'])) {
            $connection = $contextOptions[$this->protocol]['db'];
        } else {
            $connection = 'mongodb';
        }
        /* @var $connection Connection */
        $connection = Instance::ensure($connection, Connection::className());
        list($databaseName, $collectionPrefix) = explode('.', $this->namespace, 2);
        return $connection->getDatabase($databaseName)->getFileCollection($collectionPrefix);
    }