Phalcon\Db\Adapter\MongoDB\GridFS\Bucket::__construct PHP Метод

__construct() публичный Метод

Supported options: * bucketName (string): The bucket name, which will be used as a prefix for the files and chunks collections. Defaults to "fs". * chunkSizeBytes (integer): The chunk size in bytes. Defaults to 261120 (i.e. 255 KiB). * readPreference (MongoDB\Driver\ReadPreference): Read preference. * writeConcern (MongoDB\Driver\WriteConcern): Write concern.
public __construct ( MongoDB\Driver\Manager $manager, string $databaseName, array $options = [] )
$manager MongoDB\Driver\Manager Manager instance from the driver
$databaseName string Database name
$options array Bucket options
    public function __construct(Manager $manager, $databaseName, array $options = [])
    {
        $options += ['bucketName' => 'fs', 'chunkSizeBytes' => self::$defaultChunkSizeBytes];
        if (isset($options['bucketName']) && !is_string($options['bucketName'])) {
            throw InvalidArgumentException::invalidType('"bucketName" option', $options['bucketName'], 'string');
        }
        if (isset($options['chunkSizeBytes']) && !is_integer($options['chunkSizeBytes'])) {
            throw InvalidArgumentException::invalidType('"chunkSizeBytes" option', $options['chunkSizeBytes'], 'integer');
        }
        if (isset($options['readPreference']) && !$options['readPreference'] instanceof ReadPreference) {
            throw InvalidArgumentException::invalidType('"readPreference" option', $options['readPreference'], 'MongoDB\\Driver\\ReadPreference');
        }
        if (isset($options['writeConcern']) && !$options['writeConcern'] instanceof WriteConcern) {
            throw InvalidArgumentException::invalidType('"writeConcern" option', $options['writeConcern'], 'MongoDB\\Driver\\WriteConcern');
        }
        $this->databaseName = (string) $databaseName;
        $this->options = $options;
        $collectionOptions = array_intersect_key($options, ['readPreference' => 1, 'writeConcern' => 1]);
        $this->collectionWrapper = new CollectionWrapper($manager, $databaseName, $options['bucketName'], $collectionOptions);
        $this->registerStreamWrapper();
    }