VolumeInterface

Type
Interface
Namespace
craft\base
Extends
craft\base\SavableComponentInterface
Implemented by
craft\base\FlysystemVolume, craft\base\Volume, craft\volumes\Local, craft\volumes\MissingVolume, craft\volumes\Temp
Since
3.0

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.

View source

Public Methods

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

copyFile()

Copies a file.

View source

Arguments

  • $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

Signature

public abstract void copyFile ( \craft\base\string $path, \craft\base\string $newPath )

createDir()

Creates a directory.

View source

Arguments

  • $path (string) – The path of the directory, relative to the source’s root

Throws

Signature

public abstract void createDir ( \craft\base\string $path )

createFileByStream()

Creates a file.

View source

Arguments

  • $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

Signature

public abstract void createFileByStream ( \craft\base\string $path, $stream, array $config )

deleteDir()

Deletes a directory.

View source

Arguments

  • $path (string) – The path of the directory, relative to the source’s root

Throws

Signature

public abstract void deleteDir ( \craft\base\string $path )

deleteFile()

Deletes a file.

View source

Arguments

  • $path (string) – The path of the file, relative to the source’s root

Throws

Signature

public abstract void deleteFile ( \craft\base\string $path )

fileExists()

Returns whether a file exists.

View source

Arguments

  • $path (string) – The path of the file, relative to the source’s root

Returns

boolean

Signature

public abstract boolean fileExists ( \craft\base\string $path )

folderExists()

Returns whether a folder exists at the given path.

View source

Arguments

  • $path (string) – The folder path to check

Returns

boolean

Signature

public abstract boolean folderExists ( \craft\base\string $path )

getFileList()

List files.

View source

Arguments

  • $directory (string) – The path of the directory to list files of
  • $recursive (boolean) – Whether to fetch file list recursively

Returns

array

Signature

public abstract array getFileList ( \craft\base\string $directory, \craft\base\bool $recursive )

getFileMetadata()

Return the metadata about a file.

View source

Arguments

  • $uri (string) – URI to the file on the volume

Returns

array

Throws

Signature

public abstract array getFileMetadata ( \craft\base\string $uri )

getFileStream()

Gets a stream ready for reading by a file's URI.

View source

Arguments

Returns

resource

Throws

Signature

public abstract resource getFileStream ( \craft\base\string $uriPath )

getRootUrl()

Returns the URL to the source, if it’s accessible via HTTP traffic.

View source

Returns

string, false – The root URL, or false if there isn’t one

Signature

public abstract string, false getRootUrl ( )

renameDir()

Renames a directory.

View source

Arguments

  • $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

Signature

public abstract void renameDir ( \craft\base\string $path, \craft\base\string $newName )

renameFile()

Renames a file.

View source

Arguments

  • $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

Signature

public abstract void renameFile ( \craft\base\string $path, \craft\base\string $newPath )

saveFileLocally()

Save a file from the source's uriPath to a local target path.

View source

Arguments

Returns

integer – Amount of bytes copied

Signature

public abstract integer saveFileLocally ( \craft\base\string $uriPath, \craft\base\string $targetPath )

updateFileByStream()

Updates a file.

View source

Arguments

  • $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

Signature

public abstract void updateFileByStream ( \craft\base\string $path, $stream, array $config )