Craft 3 Class Reference

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.

Public Methods
Method Description Defined By
afterDelete() Performs actions after a component is deleted. craft\base\SavableComponentInterface
afterSave() Performs actions after a component is saved. craft\base\SavableComponentInterface
beforeDelete() Performs actions before a component is deleted. craft\base\SavableComponentInterface
beforeSave() Performs actions before a component is saved. craft\base\SavableComponentInterface
copyFile() Copies a file. craft\base\VolumeInterface
createDir() Creates a directory. craft\base\VolumeInterface
createFileByStream() Creates a file. craft\base\VolumeInterface
deleteDir() Deletes a directory. craft\base\VolumeInterface
deleteFile() Deletes a file. craft\base\VolumeInterface
displayName() Returns the display name of this class. craft\base\ComponentInterface
fileExists() Returns whether a file exists. craft\base\VolumeInterface
folderExists() Returns whether a folder exists at the given path. craft\base\VolumeInterface
getFileList() List files. craft\base\VolumeInterface
getFileMetadata() Return the metadata about a file. craft\base\VolumeInterface
getFileStream() Gets a stream ready for reading by a file's URI. craft\base\VolumeInterface
getIsNew() Returns whether the component is new (unsaved). craft\base\SavableComponentInterface
getRootUrl() Returns the URL to the source, if it’s accessible via HTTP traffic. craft\base\VolumeInterface
getSettings() Returns an array of the component’s settings. craft\base\SavableComponentInterface
getSettingsHtml() Returns the component’s settings HTML. craft\base\SavableComponentInterface
isSelectable() Returns whether the component should be selectable in component Type selects. craft\base\SavableComponentInterface
renameDir() Renames a directory. craft\base\VolumeInterface
renameFile() Renames a file. craft\base\VolumeInterface
saveFileLocally() Save a file from the source's uriPath to a local target path. craft\base\VolumeInterface
settingsAttributes() Returns the list of settings attribute names. craft\base\SavableComponentInterface
updateFileByStream() Updates a file. craft\base\VolumeInterface
validate() Validates the component. craft\base\SavableComponentInterface

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