PHP Класс yii\mongodb\file\StreamWrapper

Before feature can be used this wrapper should be registered via StreamWrapper::register method. It is usually performed via [[yii\mongodb\Connection::registerFileStreamWrapper()]]. Note: do not use this class directly - its instance will be created and maintained by PHP internally once corresponding stream resource is created. Resource path should be specified in following format: 'protocol://databaseName.fileCollectionPrefix?file_attribute=value' Write example: php $resource = fopen('gridfs://mydatabase.fs?filename=new_file.txt', 'w'); fwrite($resource, 'some content'); ... fclose($resource); Read example: php $resource = fopen('gridfs://mydatabase.fs?filename=my_file.txt', 'r'); $fileContent = stream_get_contents($resource);
См. также: http://php.net/manual/en/function.stream-wrapper-register.php
С версии: 2.1
Автор: Paul Klimov ([email protected])
Наследование: extends yii\base\Object
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$context associated stream resource context. This property is set automatically by PHP once wrapper is instantiated.

Открытые методы

Метод Описание
getContextOptions ( ) : array Returns options associated with [[context]].
register ( string $protocol = 'gridfs', boolean $force = false ) Registers this steam wrapper.
stream_close ( ) Closes a resource.
stream_eof ( ) : boolean Tests for end-of-file on a file pointer.
stream_flush ( ) : boolean This method is called in response to fflush() and when the stream is being closed while any unflushed data has been written to it before.
stream_open ( string $path, string $mode, integer $options, string &$openedPath ) : boolean Opens file.
stream_read ( integer $count ) : string | false Reads from stream.
stream_seek ( integer $offset, integer $whence = SEEK_SET ) : boolean Seeks to specific location in a stream.
stream_stat ( ) : array Retrieve information about a file resource.
stream_tell ( ) : integer Retrieve the current position of a stream.
stream_write ( string $data ) : integer Writes to stream.

Приватные методы

Метод Описание
fetchCollection ( ) : Collection Fetches associated file collection from stream options.
fileStatisticsTemplate ( ) : array Default template for file statistic data set.
parsePath ( string $path ) Parses stream open path, initializes internal parameters.
prepareDownload ( ) : boolean Prepares Download instance for the read operations.
prepareUpload ( ) : boolean Prepares Upload instance for the write operations.

Описание методов

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

Returns options associated with [[context]].
public getContextOptions ( ) : array
Результат array context options.

register() публичный статический Метод

Registers this steam wrapper.
public static register ( string $protocol = 'gridfs', boolean $force = false )
$protocol string name of the protocol to be used.
$force boolean whether to register wrapper, even if protocol is already taken.

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

This method is called in response to fclose().
См. также: fclose()
public stream_close ( )

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

This method is called in response to feof().
См. также: feof()
public stream_eof ( ) : boolean
Результат boolean `true` if the read/write position is at the end of the stream and if no more data is available to be read, or `false` otherwise.

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

This method is called in response to fflush() and when the stream is being closed while any unflushed data has been written to it before.
См. также: fflush()
public stream_flush ( ) : boolean
Результат boolean whether cached data was successfully stored.

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

This method is called immediately after the wrapper is initialized (f.e. by fopen() and file_get_contents()).
См. также: fopen()
public stream_open ( string $path, string $mode, integer $options, string &$openedPath ) : boolean
$path string specifies the URL that was passed to the original function.
$mode string mode used to open the file, as detailed for `fopen()`.
$options integer additional flags set by the streams API.
$openedPath string real opened path.
Результат boolean whether operation is successful.

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

This method is called in response to fread() and fgets().
См. также: fread()
public stream_read ( integer $count ) : string | false
$count integer count of bytes of data from the current position should be returned.
Результат string | false if there are less than count bytes available, return as many as are available. If no more data is available, return `false`.

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

This method is called in response to fseek().
См. также: fseek()
public stream_seek ( integer $offset, integer $whence = SEEK_SET ) : boolean
$offset integer The stream offset to seek to.
$whence integer Possible values: - SEEK_SET - Set position equal to offset bytes. - SEEK_CUR - Set position to current location plus offset. - SEEK_END - Set position to end-of-file plus offset.
Результат boolean Return true if the position was updated, false otherwise.

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

This method is called in response to stat().
См. также: stat()
public stream_stat ( ) : array
Результат array file statistic information.

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

This method is called in response to fseek() to determine the current position.
См. также: fseek()
public stream_tell ( ) : integer
Результат integer Should return the current position of the stream.

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

This method is called in response to fwrite().
См. также: fwrite()
public stream_write ( string $data ) : integer
$data string string to be stored into the underlying stream.
Результат integer the number of bytes that were successfully stored.

Описание свойств

$context публичное свойство

associated stream resource context. This property is set automatically by PHP once wrapper is instantiated.
public $context