Skip to content

FsInterface

Type
Interface
Namespace
craft\base
Extends
craft\base\BaseFsInterface, craft\base\SavableComponentInterface
Implemented by
craft\base\Fs, craft\fs\Local, craft\fs\MissingFs, craft\fs\Temp
Since
4.0.0

FsInterface defines the common interface to be implemented by filesystem classes.

A class implementing this interface should also use craft\base\SavableComponentTrait and craft\base\FsTrait.

View source

Public Methods

MethodDescription
afterDelete()Performs actions after a component is deleted.
afterSave()Performs actions after a component is saved.
beforeApplyDelete()Performs actions before a component delete is applied to the database.
beforeDelete()Performs actions before a component is deleted.
beforeSave()Performs actions before a component is saved.
copyFile()Copies a file.
createDirectory()Creates a directory.
deleteDirectory()Deletes a directory.
deleteFile()Deletes a file.
directoryExists()Returns whether a directory exists at the given path.
displayName()Returns the display name of this class.
extraFields()Returns the list of additional fields that can be returned by toArray() in addition to those listed in fields().
fields()Returns the list of fields that should be returned by default by toArray() when no specific fields are specified.
fileExists()Returns whether a file exists.
getDateModified()Returns the last time the file was modified.
getFileList()List files.
getFileSize()Return the file size.
getFileStream()Gets a stream ready for reading by a file's URI.
getIsNew()Returns whether the component is new (unsaved).
getRootUrl()Returns the root URL for a filesystem, if it has one.
getSettings()Returns an array of the component’s settings.
getSettingsHtml()Returns the component’s settings HTML.
getShowHasUrlSetting()Returns whether the “Files in this filesystem have public URLs” setting should be shown.
getShowUrlSetting()Returns whether the “Base URL” setting should be shown.
instance()Returns static class instance, which can be used to obtain meta information.
isSelectable()Returns whether the component should be selectable in component Type selects.
read()Reads contents of a file to a string.
renameDirectory()Renames a directory.
renameFile()Renames a file.
settingsAttributes()Returns the list of settings attribute names.
toArray()Converts the object into an array.
write()Writes a string to a file.
writeFileFromStream()Writes a file to a fs from a given stream.

getShowHasUrlSetting()

Since
4.5.0

Returns whether the “Files in this filesystem have public URLs” setting should be shown.

View source

Returns

boolean

getShowUrlSetting()

Since
4.5.0

Returns whether the “Base URL” setting should be shown.

If this returns false, and the filesystem has a base URL, getRootUrl() should be implemented directly, rather than storing the base URL on the craft\base\Fs::$url property.

View source

Returns

boolean