\app\framework\Component\StorageStorage

Storage class handles file storage through different storage drivers.

Summary

Methods
Properties
Constants
__construct()
keyExists()
getDriver()
getDisk()
getURL()
getContents()
setContents()
getKeys()
getTimeModified()
deleteKey()
renameKey()
isDirectory()
touchKey()
getSize()
getAbsolutePath()
getRecentKey()
supportsDirectories()
supportsTouching()
supportsAbsolutePaths()
supportsSize()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$disk
N/A

Properties

$disk

$disk : 

Type

Methods

__construct()

__construct(  $diskName) 

Parameters

$diskName

keyExists()

keyExists(  $key) 

Parameters

$key

getDriver()

getDriver() 

getDisk()

getDisk() 

getURL()

getURL(  $key) 

Parameters

$key

getContents()

getContents(string  $key) : string|boolean

Reads the contents of the file

Parameters

string $key

Returns

string|boolean —

if cannot read content

setContents()

setContents(string  $key, string  $contents, boolean  $append = false) : boolean|integer

Writes the given contents into the file

Parameters

string $key
string $contents
boolean $append

Returns

boolean|integer —

The number of bytes that were written into the file

getKeys()

getKeys(string  $key = '', boolean|integer  $recursive = false) : array

Returns an array of all keys (files and directories)

Parameters

string $key

Key of a directory to get keys from. If not set - keys will be read from the storage root.

boolean|integer $recursive

false = non-recursive, true = recursive, int = recursion depth

Returns

array

getTimeModified()

getTimeModified(string  $key, boolean  $asDateTimeObject = false) : \app\framework\Component\Storage\UNIX

Returns the last modified time

Parameters

string $key
boolean $asDateTimeObject

(Optional) Return as DateTimeObject if true

Returns

\app\framework\Component\Storage\UNIX —

Timestamp or DateTimeObject

deleteKey()

deleteKey(string  $key) : boolean

Deletes the file

Parameters

string $key

Returns

boolean

renameKey()

renameKey(string  $sourceKey, string  $targetKey) : boolean

Renames a file

Parameters

string $sourceKey

Old key

string $targetKey

New key

Returns

boolean

isDirectory()

isDirectory(string  $key) : boolean

TODO: write actual method Check if key is a directory<br /> Requires '\app\framework\Component\Storage\Driver\DirectoryAwareInterface' to be implemented by a Driver class

Parameters

string $key

Throws

\app\framework\Component\Storage\StorageException

Returns

boolean

touchKey()

touchKey(string  $key) : mixed

Touch a file (change time modified)<br /> Requires '\app\framework\Component\Storage\Driver\TouchableInterface' to be implemented by a Driver class

Parameters

string $key

Throws

\app\framework\Component\Storage\StorageException

Returns

mixed

getSize()

getSize(string  $key) : integer|boolean

Get file size<br /> Requires '\app\framework\Component\Storage\Driver\SizeAwareInterface' to be implemented by a Driver class

Parameters

string $key

Returns

integer|boolean —

The size of the file in bytes or false

getAbsolutePath()

getAbsolutePath(  $key = '') : mixed

Get absolute file path<br /> Requires '\app\framework\Component\Storage\Driver\AbsolutePathInterface' to be implemented by a Driver class

Parameters

$key

Returns

mixed

getRecentKey()

getRecentKey() 

supportsDirectories()

supportsDirectories() : boolean

Can this storage handle directories?

Returns

boolean

supportsTouching()

supportsTouching() : boolean

Can this storage touch a file?

Returns

boolean

supportsAbsolutePaths()

supportsAbsolutePaths() : boolean

Can this storage handle absolute paths?

Returns

boolean

supportsSize()

supportsSize() : boolean

Can this storage get file size info?

Returns

boolean