PHP Class Webiny\Component\Storage\Directory\Directory

Inheritance: implements Webiny\Component\Storage\Directory\DirectoryInterface, implements IteratorAggregate, use trait Webiny\Component\StdLib\StdLibTrait, use trait Webiny\Component\EventManager\EventManagerTrait
Show file Open project: Webiny/Framework

Protected Properties

Property Type Description
$items
$key
$recursive
$regex
$storage

Public Methods

Method Description
__construct ( string $key, Storage $storage, boolean $recursive = false, null | string $filter = null ) Constructor
count ( ) : integer Count number of items in a directory
delete ( $fireStorageEvents = true )
filter ( string $condition ) : Directory Filter items in a directory using given regex or extension.
getAbsolutePath ( ) : string Get absolute folder path
getIterator ( ) : Traversable (PHP 5 >= 5.0.0)
Retrieve an external iterator
getKey ( ) : string Get directory key
getSize ( ) Get directory size
getStorage ( ) : Storage Get Storage used by the DirectoryInterface instance
isDirectory ( ) : boolean Checks if file is a directory.

Protected Methods

Method Description
loadItems ( )
parseFilter ( $filter )

Method Details

__construct() public method

Constructor
public __construct ( string $key, Storage $storage, boolean $recursive = false, null | string $filter = null )
$key string File key
$storage Webiny\Component\Storage\Storage Storage to use
$recursive boolean (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.
$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

delete() public method

public delete ( $fireStorageEvents = true )

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 ( string $condition ) : Directory
$condition string
return Directory

getAbsolutePath() public method

Get absolute folder path
public getAbsolutePath ( ) : string
return string

getIterator() public method

(PHP 5 >= 5.0.0)
Retrieve an external iterator
public getIterator ( ) : Traversable
return Traversable An instance of an object implementing Iterator or Traversable

getKey() public method

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

getSize() public method

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.
public getSize ( )

getStorage() public method

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

isDirectory() public static method

Checks if file is a directory.
public static isDirectory ( ) : boolean
return boolean

loadItems() protected method

protected loadItems ( )

parseFilter() protected method

protected parseFilter ( $filter )

Property Details

$items protected property

protected $items

$key protected property

protected $key

$recursive protected property

protected $recursive

$regex protected property

protected $regex

$storage protected property

protected $storage