PHP Class Webiny\Component\Storage\Storage

Inheritance: use trait Webiny\Component\StdLib\ComponentTrait
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
__construct ( Webiny\Component\Storage\Driver\DriverInterface $driver )
deleteKey ( string $key ) : boolean Deletes the file
getAbsolutePath ( $key = '' ) : mixed Get absolute file path
Requires '\Webiny\Component\Storage\Driver\AbsolutePathInterface' to be implemented by a Driver class
getContents ( $key ) : string | boolean Reads the contents of the file
getDriver ( ) : Webiny\Component\Storage\Driver\DriverInterface
getKeys ( string $key = '', boolean | integer $recursive = false ) : array Returns an array of all keys (files and directories)
getRecentKey ( )
getSize ( string $key ) : integer | boolean Get file size
Requires '\Webiny\Component\Storage\Driver\SizeAwareInterface' to be implemented by a Driver class
getTimeModified ( string $key, boolean $asDateTimeObject = false ) : UNIX Returns the last modified time
getURL ( $key )
isDirectory ( string $key ) : boolean Check if key is a directory
Requires '\Webiny\Component\Storage\Driver\DirectoryAwareInterface' to be implemented by a Driver class
keyExists ( string $key ) : boolean Indicates whether the key exists
renameKey ( string $sourceKey, string $targetKey ) : boolean Renames a file
setContents ( string $key, string $contents, boolean $append = false ) : boolean | integer Writes the given contents into the file
supportsAbsolutePaths ( ) : mixed Can this storage handle absolute paths?
supportsDirectories ( ) : mixed Can this storage handle directories?
supportsSize ( ) : mixed Can this storage get file size info?
supportsTouching ( ) : mixed Can this storage touch a file?
touchKey ( string $key ) : mixed Touch a file (change time modified)
Requires '\Webiny\Component\Storage\Driver\TouchableInterface' to be implemented by a Driver class

Method Details

__construct() public method

public __construct ( Webiny\Component\Storage\Driver\DriverInterface $driver )
$driver Webiny\Component\Storage\Driver\DriverInterface

deleteKey() public method

Deletes the file
public deleteKey ( string $key ) : boolean
$key string
return boolean

getAbsolutePath() public method

Get absolute file path
Requires '\Webiny\Component\Storage\Driver\AbsolutePathInterface' to be implemented by a Driver class
public getAbsolutePath ( $key = '' ) : mixed
$key
return mixed

getContents() public method

Reads the contents of the file
public getContents ( $key ) : string | boolean
return string | boolean if cannot read content

getDriver() public method

public getDriver ( ) : Webiny\Component\Storage\Driver\DriverInterface
return Webiny\Component\Storage\Driver\DriverInterface

getKeys() public method

Returns an array of all keys (files and directories)
public getKeys ( string $key = '', boolean | integer $recursive = false ) : array
$key string Key of a directory to get keys from. If not set - keys will be read from the storage root.
$recursive boolean | integer false = non-recursive, true = recursive, int = recursion depth
return array

getRecentKey() public method

public getRecentKey ( )

getSize() public method

Get file size
Requires '\Webiny\Component\Storage\Driver\SizeAwareInterface' to be implemented by a Driver class
public getSize ( string $key ) : integer | boolean
$key string
return integer | boolean The size of the file in bytes or false

getTimeModified() public method

Returns the last modified time
public getTimeModified ( string $key, boolean $asDateTimeObject = false ) : UNIX
$key string
$asDateTimeObject boolean (Optional) Return as DateTimeObject if true
return UNIX Timestamp or DateTimeObject

getURL() public method

public getURL ( $key )

isDirectory() public method

Check if key is a directory
Requires '\Webiny\Component\Storage\Driver\DirectoryAwareInterface' to be implemented by a Driver class
public isDirectory ( string $key ) : boolean
$key string
return boolean

keyExists() public method

Indicates whether the key exists
public keyExists ( string $key ) : boolean
$key string
return boolean

renameKey() public method

Renames a file
public renameKey ( string $sourceKey, string $targetKey ) : boolean
$sourceKey string Old key
$targetKey string New key
return boolean

setContents() public method

Writes the given contents into the file
public setContents ( string $key, string $contents, boolean $append = false ) : boolean | integer
$key string
$contents string
$append boolean
return boolean | integer The number of bytes that were written into the file

supportsAbsolutePaths() public method

Can this storage handle absolute paths?
public supportsAbsolutePaths ( ) : mixed
return mixed

supportsDirectories() public method

Can this storage handle directories?
public supportsDirectories ( ) : mixed
return mixed

supportsSize() public method

Can this storage get file size info?
public supportsSize ( ) : mixed
return mixed

supportsTouching() public method

Can this storage touch a file?
public supportsTouching ( ) : mixed
return mixed

touchKey() public method

Touch a file (change time modified)
Requires '\Webiny\Component\Storage\Driver\TouchableInterface' to be implemented by a Driver class
public touchKey ( string $key ) : mixed
$key string
return mixed