Volumes

Type
Class
Namespace
craft\services
Inherits
craft\services\Volumes » yii\base\Component » yii\base\BaseObject
Implements
yii\base\Configurable
Since
3.0

Class AssetVolumesService

See also http://craftcms.com

View source

Public Properties

$allVolumeIds

Type
array
Access
Read-only

View source

Signature

public array getAllVolumeIds ( )

$allVolumeTypes

Type
string[]
Access
Read-only

View source

Signature

public string[] getAllVolumeTypes ( )

$allVolumes

Signature

public craft\base\VolumeInterface[] getAllVolumes ( )

$publicVolumeIds

Type
integer[]
Access
Read-only

View source

Signature

public integer[] getPublicVolumeIds ( )

$publicVolumes

Signature

public craft\base\VolumeInterface[] getPublicVolumes ( )

$totalViewableVolumes

Type
integer
Access
Read-only

View source

Signature

public integer getTotalViewableVolumes ( )

$totalVolumes

Type
integer
Access
Read-only

View source

Signature

public integer getTotalVolumes ( )

$viewableVolumeIds

Type
array
Access
Read-only

View source

Signature

public array getViewableVolumeIds ( )

$viewableVolumes

Signature

public craft\base\VolumeInterface[] getViewableVolumes ( )

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 an object property.
__isset()Checks if a property is set, i.e. defined and not null.
__set()Sets value of an object property.
__unset()Sets an object property to 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.
createVolume()Creates an asset volume with a given config.
deleteVolume()Deletes an asset volume.
deleteVolumeById()Deletes an asset volume by its ID.
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.
ensureTopFolder()Ensures a top level folder exists that matches the model.
getAllVolumeIds()Returns all of the volume IDs.
getAllVolumeTypes()Returns all registered volume types.
getAllVolumes()Returns all volumes.
getBehavior()Returns the named behavior object.
getBehaviors()Returns all behaviors attached to this component.
getPublicVolumeIds()Returns all volume IDs that have public URLs.
getPublicVolumes()Returns all volumes that have public URLs.
getTotalViewableVolumes()Returns the total number of volumes that are viewable by the current user.
getTotalVolumes()Returns the total number of volumes.
getViewableVolumeIds()Returns all volume IDs that are viewable by the current user.
getViewableVolumes()Returns all volumes that are viewable by the current user.
getVolumeByHandle()Returns a volumn by its handle.
getVolumeById()Returns a volume by its ID.
getVolumeOverrides()Returns any custom volume config values.
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.
init()Initializes the object.
off()Detaches an existing event handler from this component.
on()Attaches an event handler to an event.
reorderVolumes()Reorders asset volumes.
saveVolume()Saves an asset volume.
trigger()Triggers an event.

createVolume()

Creates an asset volume with a given config.

View source

Arguments

  • $config (mixed) – The asset volume’s class name, or its config, with a type value and optionally a settings value

Returns

craft\base\VolumeInterface – The asset volume

Signature

public craft\base\VolumeInterface createVolume ( $config )

deleteVolume()

Deletes an asset volume.

View source

Arguments

Returns

boolean

Throws

Signature

public boolean deleteVolume ( craft\base\VolumeInterface $volume )

deleteVolumeById()

Deletes an asset volume by its ID.

View source

Arguments

Returns

boolean

Throws

Signature

public boolean deleteVolumeById ( \craft\services\int $volumeId )

ensureTopFolder()

Ensures a top level folder exists that matches the model.

View source

Arguments

Returns

integer

Signature

public integer ensureTopFolder ( craft\base\VolumeInterface $volume )

getAllVolumeIds()

Returns all of the volume IDs.

View source

Returns

array

Signature

public array getAllVolumeIds ( )

getAllVolumeTypes()

Returns all registered volume types.

View source

Returns

string[]

Signature

public string[] getAllVolumeTypes ( )

getAllVolumes()

Returns all volumes.

View source

Returns

craft\base\VolumeInterface[]

Signature

public craft\base\VolumeInterface[] getAllVolumes ( )

getPublicVolumeIds()

Returns all volume IDs that have public URLs.

View source

Returns

integer[]

Signature

public integer[] getPublicVolumeIds ( )

getPublicVolumes()

Returns all volumes that have public URLs.

View source

Returns

craft\base\VolumeInterface[]

Signature

public craft\base\VolumeInterface[] getPublicVolumes ( )

getTotalViewableVolumes()

Returns the total number of volumes that are viewable by the current user.

View source

Returns

integer

Signature

public integer getTotalViewableVolumes ( )

getTotalVolumes()

Returns the total number of volumes.

View source

Returns

integer

Signature

public integer getTotalVolumes ( )

getViewableVolumeIds()

Returns all volume IDs that are viewable by the current user.

View source

Returns

array

Signature

public array getViewableVolumeIds ( )

getViewableVolumes()

Returns all volumes that are viewable by the current user.

View source

Returns

craft\base\VolumeInterface[]

Signature

public craft\base\VolumeInterface[] getViewableVolumes ( )

getVolumeByHandle()

Returns a volumn by its handle.

View source

Arguments

Returns

craft\base\VolumeInterface, null

Signature

public craft\base\VolumeInterface, null getVolumeByHandle ( \craft\services\string $handle )

getVolumeById()

Returns a volume by its ID.

View source

Arguments

Returns

craft\base\VolumeInterface, null

Signature

public craft\base\VolumeInterface, null getVolumeById ( \craft\services\int $volumeId )

getVolumeOverrides()

Returns any custom volume config values.

View source

Arguments

  • $handle (string) – The volume handle

Returns

array, null

Signature

public array, null getVolumeOverrides ( \craft\services\string $handle )

reorderVolumes()

Reorders asset volumes.

View source

Arguments

Returns

boolean

Throws

Signature

public boolean reorderVolumes ( array $volumeIds )

saveVolume()

Saves an asset volume.

View source

Arguments

Returns

boolean – Whether the field was saved successfully

Throws

Signature

public boolean saveVolume ( craft\base\VolumeInterface $volume, \craft\services\bool $runValidation = true )

Events

EVENT_AFTER_DELETE_VOLUME

Type
craft\events\VolumeEvent

The event that is triggered after a Asset volume is deleted.

EVENT_AFTER_SAVE_VOLUME

Type
craft\events\VolumeEvent

The event that is triggered after an Asset volume is saved.

EVENT_BEFORE_DELETE_VOLUME

Type
craft\events\VolumeEvent

The event that is triggered before an Asset volume is deleted.

EVENT_BEFORE_SAVE_VOLUME

Type
craft\events\VolumeEvent

The event that is triggered before an Asset volume is saved.

EVENT_REGISTER_VOLUME_TYPES

Type
craft\events\RegisterComponentTypesEvent

The event that is triggered when registering volume types.

Volume types must implement craft\base\VolumeInterface. craft\base\Volume provides a base implementation.

See Volume Types for documentation on creating volume types.

Example