\app\framework\Component\Storage\DirectoryDirectory

Summary

Methods
Properties
Constants
__construct()
getSize()
getKey()
getStorage()
getAbsolutePath()
getIterator()
filter()
count()
isDirectory()
delete()
No public properties found
No constants found
serialize()
unserialize()
eventManager()
parseFilter()
loadItems()
$key
$storage
$recursive
$items
$regex
N/A
No private methods found
No private properties found
N/A

Properties

$key

$key : 

Type

$storage

$storage : 

Type

$recursive

$recursive : 

Type

$items

$items : 

Type

$regex

$regex : 

Type

Methods

__construct()

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

Constructor

Parameters

string $key

File key

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

Storage to use

boolean $recursive

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

null|string $filter

(Optional) Filter to use when reading directory items

getSize()

getSize() 

Get directory size

WARNING! This is a very intensive operation especially on deep directory structures! It is performed by recursively walking through directory structure and getting each file's size.

getKey()

getKey() : string

Get directory key

Returns

string —

Directory key

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

getAbsolutePath()

getAbsolutePath() : string

Get absolute folder path

Returns

string

getIterator()

getIterator() : \Traversable

(PHP 5 &gt;= 5.0.0)<br/> Retrieve an external iterator

Returns

\Traversable —

An instance of an object implementing Iterator or Traversable

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

isDirectory()

isDirectory() : boolean

Checks if file is a directory.

Returns

boolean

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

serialize()

serialize(  $value) : string

Serializes the given value.

Parameters

$value

Returns

string

unserialize()

unserialize(string  $string) : array|mixed

Unserializes the given string and returns the array.

Parameters

string $string

String to serialize.

Returns

array|mixed

parseFilter()

parseFilter(  $filter) 

Parameters

$filter

loadItems()

loadItems()