modxcms/revolution — pull request #11295 by exside (2014-04-19 18:06:26+00:00)
Title: modFileHandler enhancement: added modDirectory getFiles() method

It seemed not to be possible to get a list of all files in a folder represented by a modDirectory object, this method adds this functionality. It can do several things:

1) Scan the modDirectory path recursively or normally (non-recursive) with folders ignored (only filepaths are returned)
2) It can return or ignore (default) hidden (unix filesystems) files and folders starting with a dot (e.g. .htaccess etc.)
3) It can filter the returned filelist by file extensions passed via $options
4) It can sort the resulting filelist array alphabetically if desired (this maybe should be done by the user him/herself when working with the returned filelist array...but I thought it's maybe handy)

I think this could may be also of use for file mediasources, as they may implement a directoryiterator themselves, like this they could just make use of this method already provided by the filehandler...

usage example:

```
// get the filehandler service
$modx->getService('file','modFileHandler');

// create modFileHandler object, in this case we need a modDirectory object, eg. pass a folder path
$fileobj = $modx->file->make(MODX_ASSETS_PATH . 'site/test/');

// now we want all files contained inside this folder, recursively but unsorted, filtered by css file extension
$files = $fileobj->getFiles(array('recursive' => true, 'sort' => false, 'extensions' => 'css', 'ignorehidden' => true));

echo '

' . print_r($files,1) . '

';
```