Interface craft\base\VolumeInterface
- Extends
- craft\base\SavableComponentInterface
- Implemented by
- craft\base\FlysystemVolume, craft\base\Volume, craft\volumes\Local, craft\volumes\MissingVolume, craft\volumes\Temp
- Available since version
- 3.0
- Source Code
- https://github.com/craftcms/cms/blob/master/src/base/VolumeInterface.php
VolumeInterface defines the common interface to be implemented by volume classes.
A class implementing this interface should also use craft\base\SavableComponentTrait and craft\base\VolumeTrait.
Method Details
copyFile()
public abstract method
#
Copies a file.
public abstract void copyFile ( \craft\base\string $path, \craft\base\string $newPath )
$path |
string | The path of the file, relative to the source’s root |
$newPath |
string | The path of the new file, relative to the source’s root |
throws | craft\errors\VolumeObjectExistsException | if a file with such a name exists already |
---|---|---|
throws | craft\errors\VolumeObjectNotFoundException | if the file to be renamed cannot be found |
throws | craft\errors\VolumeException | if something else goes wrong |
createDir()
public abstract method
#
Creates a directory.
public abstract void createDir ( \craft\base\string $path )
$path |
string | The path of the directory, relative to the source’s root |
throws | craft\errors\VolumeObjectExistsException | if a directory with such name already exists |
---|---|---|
throws | craft\errors\VolumeException | if something else goes wrong |
createFileByStream()
public abstract method
#
Creates a file.
public abstract void createFileByStream ( \craft\base\string $path, $stream, array $config )
$path |
string | The path of the file, relative to the source’s root |
$stream |
resource | The stream to file |
$config |
array | Additional config options to pass to the adapter |
throws | craft\errors\VolumeObjectExistsException | if a file already exists at the path on the Volume |
---|---|---|
throws | craft\errors\VolumeException | if something else goes wrong |
deleteDir()
public abstract method
#
Deletes a directory.
public abstract void deleteDir ( \craft\base\string $path )
$path |
string | The path of the directory, relative to the source’s root |
throws | craft\errors\VolumeException | if something goes wrong |
---|
deleteFile()
public abstract method
#
Deletes a file.
public abstract void deleteFile ( \craft\base\string $path )
$path |
string | The path of the file, relative to the source’s root |
throws | craft\errors\VolumeException | if something goes wrong |
---|
fileExists()
public abstract method
#
Returns whether a file exists.
public abstract boolean fileExists ( \craft\base\string $path )
$path |
string | The path of the file, relative to the source’s root |
folderExists()
public abstract method
#
Returns whether a folder exists at the given path.
public abstract boolean folderExists ( \craft\base\string $path )
$path |
string | The folder path to check |
getFileList()
public abstract method
#
List files.
public abstract array getFileList ( \craft\base\string $directory, \craft\base\bool $recursive )
$directory |
string | The path of the directory to list files of |
$recursive |
boolean | Whether to fetch file list recursively |
getFileMetadata()
public abstract method
#
Return the metadata about a file.
public abstract array getFileMetadata ( \craft\base\string $uri )
$uri |
string | URI to the file on the volume |
throws | craft\errors\VolumeObjectNotFoundException | if the file cannot be found |
---|
getFileStream()
public abstract method
#
Gets a stream ready for reading by a file's URI.
public abstract resource getFileStream ( \craft\base\string $uriPath )
$uriPath |
string | |
throws | craft\errors\AssetException | if a stream cannot be created |
---|
getRootUrl()
public abstract method
#
Returns the URL to the source, if it’s accessible via HTTP traffic.
public abstract string, false getRootUrl ( )
return | string, false | The root URL, or false if there isn’t one
|
---|
renameDir()
public abstract method
#
Renames a directory.
public abstract void renameDir ( \craft\base\string $path, \craft\base\string $newName )
$path |
string | The path of the directory, relative to the source’s root |
$newName |
string | The new path of the directory, relative to the source’s root |
throws | craft\errors\VolumeObjectNotFoundException | if a directory with such name already exists |
---|---|---|
throws | craft\errors\VolumeObjectExistsException | if a directory with such name already exists |
throws | craft\errors\VolumeException | if something else goes wrong |
renameFile()
public abstract method
#
Renames a file.
public abstract void renameFile ( \craft\base\string $path, \craft\base\string $newPath )
$path |
string | The old path of the file, relative to the source’s root |
$newPath |
string | The new path of the file, relative to the source’s root |
throws | craft\errors\VolumeObjectExistsException | if a file with such a name exists already |
---|---|---|
throws | craft\errors\VolumeObjectNotFoundException | if the file to be renamed cannot be found |
throws | craft\errors\VolumeException | if something else goes wrong |
saveFileLocally()
public abstract method
#
Save a file from the source's uriPath to a local target path.
public abstract integer saveFileLocally ( \craft\base\string $uriPath, \craft\base\string $targetPath )
$uriPath |
string | |
$targetPath |
string | |
return | integer | Amount of bytes copied |
---|
updateFileByStream()
public abstract method
#
Updates a file.
public abstract void updateFileByStream ( \craft\base\string $path, $stream, array $config )
$path |
string | The path of the file, relative to the source’s root |
$stream |
resource | The new contents of the file as a stream |
$config |
array | Additional config options to pass to the adapter |
throws | craft\errors\VolumeObjectNotFoundException | if the file to be updated cannot be found |
---|---|---|
throws | craft\errors\VolumeException | if something else goes wrong |