PHP Interface Webiny\Component\Storage\Directory\DirectoryInterface

Show file Open project: Webiny/Framework

Public Methods

Method Description
__construct ( string $key, Storage $storage, boolean $treeStructure = true, null | string $filter = null ) Constructor
count ( ) : integer Count number of items in a directory
delete ( boolean $fireStorageEvents = true ) : boolean Delete directory and all of it's contents recursively
filter ( $condition ) Filter items in a directory using given regex or extension.
getKey ( ) : string Get directory key
getStorage ( ) : Storage Get Storage used by the DirectoryInterface instance

Method Details

__construct() public method

Constructor
public __construct ( string $key, Storage $storage, boolean $treeStructure = true, null | string $filter = null )
$key string File key
$storage Webiny\Component\Storage\Storage Storage to use
$treeStructure boolean (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.
$filter null | string (Optional) Filter to use when reading directory items

count() public method

Count number of items in a directory
public count ( ) : integer
return integer Number of items in the directory

delete() public method

Delete directory and all of it's contents recursively
public delete ( boolean $fireStorageEvents = true ) : boolean
$fireStorageEvents boolean (Optional) If you don't want to fire StorageEvent::FILE_DELETED set this to false
return boolean

filter() public method

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/'
public filter ( $condition )
$condition

getKey() public method

Get directory key
public getKey ( ) : string
return string Directory key

getStorage() public method

Get Storage used by the DirectoryInterface instance
public getStorage ( ) : Storage
return Webiny\Component\Storage\Storage Storage instance used for this directory