StreamWrapperAdapter
class StreamWrapperAdapter (View source)
A generic stream wrapper sitting between PHP and stream wrappers implementing StreamWrapperInterface.
The resource manager will register configured stream wrappers with this class, enabling the use of Flow goodies like DI in those stream wrappers.
Instances of this class are created by PHP itself and therefore are unknown to Flow's object registry.
Properties
static protected array | $registeredStreamWrappers | ||
resource | $context | ||
protected StreamWrapperInterface | $streamWrapper |
Methods
Initialize StreamWrappers with this adapter
Register a stream wrapper. Later registrations for a scheme will override earlier ones without warning.
Returns the stream wrappers registered with this class.
Create the internal stream wrapper if needed.
Close directory handle.
Open directory handle.
Read entry from directory handle.
Rewind directory handle.
Create a directory.
Renames a file or directory.
Removes a directory.
Retrieve the underlaying resource.
Close an resource.
Tests for end-of-file on a file pointer.
Flushes the output.
Advisory file locking.
Opens file or URL.
Read from stream.
Seeks to specific location in a stream.
Change stream options.
Retrieve information about a file resource.
Retrieve the current position of a stream.
Write to stream.
Delete a file.
Retrieve information about a file.
Returns all class names implementing the StreamWrapperInterface.
Details
static void
initializeStreamWrapper(ObjectManagerInterface $objectManager)
Initialize StreamWrappers with this adapter
static void
registerStreamWrapper(string $scheme, string $objectName)
Register a stream wrapper. Later registrations for a scheme will override earlier ones without warning.
static array
getRegisteredStreamWrappers()
Returns the stream wrappers registered with this class.
protected void
createStreamWrapper(string $path)
Create the internal stream wrapper if needed.
bool
dir_closedir()
Close directory handle.
This method is called in response to closedir().
Any resources which were locked, or allocated, during opening and use of the directory stream should be released.
bool
dir_opendir(string $path, int $options)
Open directory handle.
This method is called in response to opendir().
string
dir_readdir()
Read entry from directory handle.
This method is called in response to readdir().
bool
dir_rewinddir()
Rewind directory handle.
This method is called in response to rewinddir().
Should reset the output generated by dir_readdir(). I.e.: The next call to dir_readdir() should return the first entry in the location returned by dir_opendir().
bool
mkdir(string $path, int $mode, int $options)
Create a directory.
This method is called in response to mkdir().
Note: In order for the appropriate error message to be returned this method should not be defined if the wrapper does not support creating directories.
bool
rename(string $path_from, string $path_to)
Renames a file or directory.
This method is called in response to rename().
Should attempt to rename path_from to path_to.
Note: In order for the appropriate error message to be returned this method should not be defined if the wrapper does not support creating directories.
bool
rmdir(string $path, int $options)
Removes a directory.
This method is called in response to rmdir().
Note: In order for the appropriate error message to be returned this method should not be defined if the wrapper does not support creating directories.
resource
stream_cast(int $cast_as)
Retrieve the underlaying resource.
This method is called in response to stream_select().
void
stream_close()
Close an resource.
This method is called in response to fclose().
All resources that were locked, or allocated, by the wrapper should be released.
bool
stream_eof()
Tests for end-of-file on a file pointer.
This method is called in response to feof().
bool
stream_flush()
Flushes the output.
This method is called in response to fflush().
If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now.
Note: If not implemented, false is assumed as the return value.
bool
stream_lock(int $operation)
Advisory file locking.
This method is called in response to flock(), when file_put_contents() (when flags contains LOCK_EX), stream_set_blocking() and when closing the stream (LOCK_UN).
$operation is one of the following: LOCK_SH to acquire a shared lock (reader). LOCK_EX to acquire an exclusive lock (writer). LOCK_UN to release a lock (shared or exclusive). LOCK_NB if you don't want flock() to block while locking.
bool
stream_open(string $path, string $mode, int $options, string $opened_path)
Opens file or URL.
This method is called immediately after the wrapper is initialized (f.e. by fopen() and file_get_contents()).
$options can hold one of the following values OR'd together: STREAM_USE_PATH If path is relative, search for the resource using the include_path. STREAM_REPORT_ERRORS If this flag is set, you are responsible for raising errors using trigger_error() during opening of the stream. If this flag is not set, you should not raise any errors.
string
stream_read(int $count)
Read from stream.
This method is called in response to fread() and fgets().
Note: Remember to update the read/write position of the stream (by the number of bytes that were successfully read).
bool
stream_seek(int $offset, int $whence = SEEK_SET)
Seeks to specific location in a stream.
This method is called in response to fseek().
The read/write position of the stream should be updated according to the offset and whence .
$whence can one of: 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.
bool
stream_set_option(int $option, int $arg1, int $arg2)
Change stream options.
This method is called to set options on the stream.
$option can be one of: STREAM_OPTION_BLOCKING (The method was called in response to stream_set_blocking()) STREAM_OPTION_READ_TIMEOUT (The method was called in response to stream_set_timeout()) STREAM_OPTION_WRITE_BUFFER (The method was called in response to stream_set_write_buffer())
If $option is ... then $arg1 is set to: STREAM_OPTION_BLOCKING: requested blocking mode (1 meaning block 0 not blocking). STREAM_OPTION_READ_TIMEOUT: the timeout in seconds. STREAM_OPTION_WRITE_BUFFER: buffer mode (STREAM_BUFFER_NONE or STREAM_BUFFER_FULL).
If $option is ... then $arg2 is set to: STREAM_OPTION_BLOCKING: This option is not set. STREAM_OPTION_READ_TIMEOUT: the timeout in microseconds. STREAM_OPTION_WRITE_BUFFER: the requested buffer size.
array
stream_stat()
Retrieve information about a file resource.
This method is called in response to fstat().
int
stream_tell()
Retrieve the current position of a stream.
This method is called in response to ftell().
int
stream_write(string $data)
Write to stream.
This method is called in response to fwrite().
If there is not enough room in the underlying stream, store as much as possible.
Note: Remember to update the current position of the stream by number of bytes that were successfully written.
bool
unlink(string $path)
Delete a file.
This method is called in response to unlink().
Note: In order for the appropriate error message to be returned this method should not be defined if the wrapper does not support removing files.
array
url_stat(string $path, int $flags)
Retrieve information about a file.
This method is called in response to all stat() related functions.
$flags can hold one or more of the following values OR'd together: STREAM_URL_STAT_LINK For resources with the ability to link to other resource (such as an HTTP Location: forward, or a filesystem symlink). This flag specified that only information about the link itself should be returned, not the resource pointed to by the link. This flag is set in response to calls to lstat(), is_link(), or filetype(). STREAM_URL_STAT_QUIET If this flag is set, your wrapper should not raise any errors. If this flag is not set, you are responsible for reporting errors using the trigger_error() function during stating of the path.
static array
getStreamWrapperImplementationClassNames(ObjectManagerInterface $objectManager)
Returns all class names implementing the StreamWrapperInterface.