\app\framework\Component\Storage\DirectoryDirectoryInterface

Basic Directory interface

Summary

Methods
Constants
__construct()
filter()
count()
getStorage()
getKey()
delete()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

__construct()

__construct(string  $key, \app\framework\Component\Storage\Storage  $storage, boolean  $treeStructure = true, null|string  $filter = null) 

Constructor

Parameters

string $key

File key

\app\framework\Component\Storage\Storage $storage

Storage to use

boolean $treeStructure

(Optional) By default, Directory will only read the first level if items. If set to false, Directory will read all children items and list them as one-dimensional array.

null|string $filter

(Optional) Filter to use when reading directory items

filter()

filter(  $condition) : $this

Filter items in a directory using given regex or extension.

Example 1: '.pdf' ($condition starting with means: anything that ends with)

Example 2: 'file' ($condition ending with means: anything that starts with)

Example 3: Any file that ends with file.zip: '/(\S+)?file.zip/'

Parameters

$condition

Returns

$this —

DirectoryInterface object containing only filtered values

count()

count() : integer

Count number of items in a directory

Returns

integer —

Number of items in the directory

getStorage()

getStorage() : \app\framework\Component\Storage\Storage

Get Storage used by the DirectoryInterface instance

Returns

\app\framework\Component\Storage\Storage

Storage instance used for this directory

getKey()

getKey() : string

Get directory key

Returns

string —

Directory key

delete()

delete(boolean  $fireStorageEvents = true) : boolean

Delete directory and all of it's contents recursively

Parameters

boolean $fireStorageEvents

(Optional) If you don't want to fire StorageEvent::FILE_DELETED set this to false

Returns

boolean