Skip to content

Fs ​

Type
Class
Namespace
craft\services
Inherits
craft\services\Fs » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
4.0.0

Filesystems service.

An instance of the service is available via \craft\base\ApplicationTrait::getfs().

View source

Public Properties ​

PropertyDescription
allFilesystemTypesstring[] – All registered filesystem types
allFilesystemscraft\base\FsInterface[] – All filesystems
behaviorsyii\base\Behavior – List of behaviors attached to this component.

allFilesystemTypes ​

Type
string[]
Default value
null

All registered filesystem types

View source

allFilesystems ​

Type
craft\base\FsInterface[]
Default value
null

All filesystems

View source

Public Methods ​

MethodDescription
__call()Calls the named method which is not a class method.
__clone()This method is called after the object is created by cloning an existing one.
__construct()Constructor.
__get()Returns the value of a component property.
__isset()Checks if a property is set, i.e. defined and not null.
__serialize()Serializer
__set()Sets the value of a component property.
__unset()Sets a component property to be null.
attachBehavior()Attaches a behavior to this component.
attachBehaviors()Attaches a list of behaviors to the component.
behaviors()Returns a list of behaviors that this component should behave as.
canGetProperty()Returns a value indicating whether a property can be read.
canSetProperty()Returns a value indicating whether a property can be set.
className()Returns the fully qualified name of this class.
createFilesystem()Creates a filesystem from a given config.
createFilesystemConfig()Returns the config for the given filesystem.
detachBehavior()Detaches a behavior from the component.
detachBehaviors()Detaches all behaviors from the component.
ensureBehaviors()Makes sure that the behaviors declared in behaviors() are attached to this component.
getAllFilesystemTypes()Returns all registered filesystem types.
getAllFilesystems()Returns all filesystems.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getFilesystemByHandle()Returns a filesystem by its handle.
hasEventHandlers()Returns a value indicating whether there is any handler attached to the named event.
hasMethod()Returns a value indicating whether a method is defined.
hasProperty()Returns a value indicating whether a property is defined for this component.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
removeFilesystem()Removes a filesystem.
saveFilesystem()Creates or updates a filesystem.
trigger()Triggers an event.

__serialize() ​

Serializer

View source

createFilesystem() ​

Creates a filesystem from a given config.

View source

Arguments ​

  • $config (string, array) – The filesystem’s class name, or its config, with a type value and optionally a settings value

Returns ​

\craft\services\T – The filesystem

createFilesystemConfig() ​

Returns the config for the given filesystem.

View source

Arguments ​

Returns ​

array

getAllFilesystemTypes() ​

Returns all registered filesystem types.

View source

Returns ​

string[]

getAllFilesystems() ​

Returns all filesystems.

View source

Returns ​

craft\base\FsInterface[]

getFilesystemByHandle() ​

Returns a filesystem by its handle.

View source

Arguments ​

Returns ​

craft\base\FsInterface, null

removeFilesystem() ​

Removes a filesystem.

View source

Arguments ​

Returns ​

boolean

Throws ​

saveFilesystem() ​

Creates or updates a filesystem.

View source

Arguments ​

Returns ​

boolean – Whether the filesystem was saved successfully

Throws ​

Events ​

EVENT_REGISTER_FILESYSTEM_TYPES ​

Type
craft\events\RegisterComponentTypesEvent

The event that is triggered when registering filesystem types.


EVENT_RENAME_FILESYSTEM ​

Type
craft\events\FsEvent

The event that is triggered after a filesystem is renamed.