Skip to content

Commit

Permalink
Fix FileManager to use originals parameter instead of hard coded 'ori…
Browse files Browse the repository at this point in the history
…ginals' Fixes punkave#25
  • Loading branch information
zorfling committed Jan 28, 2014
1 parent 988bb59 commit 662b8c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ services:
arguments:
# For bc reasons we're not changing the names of the parameters
- file_base_path: '%file_uploader.file_base_path%'
originals: '%file_uploader.originals%'

punk_ave.twig.file_extension:
class: PunkAve\FileUploaderBundle\Twig\FileExtension
Expand Down
10 changes: 6 additions & 4 deletions Services/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ public function __construct($options)
}

/**
* Get a list of files already present. The 'folder' option is required.
* Get a list of files already present. The 'folder' option is required.
* If you pass consistent options to this method and handleFileUpload with
* regard to paths, then you will get consistent results.
*/
public function getFiles($options = array())
{
$options = array_merge($this->options, $options);

$originals = $options['originals'];

$folder = $options['file_base_path'] . '/' . $options['folder'];
if (file_exists($folder))
{
$dirs = glob("$folder/originals/*");
$dirs = glob($folder . '/' . $originals['folder'] . '/*');
$fullPath = isset($options['full_path']) ? $options['full_path'] : false;
if ($fullPath)
{
Expand Down Expand Up @@ -68,11 +70,11 @@ public function removeFiles($options = array())
/**
* Sync existing files from one folder to another. The 'fromFolder' and 'toFolder'
* options are required. As with the 'folder' option elsewhere, these are appended
* to the file_base_path for you, missing parent folders are created, etc. If
* to the file_base_path for you, missing parent folders are created, etc. If
* 'fromFolder' does not exist no error is reported as this is common if no files
* have been uploaded. If there are files and the sync reports errors an exception
* is thrown.
*
*
* If you pass consistent options to this method and handleFileUpload with
* regard to paths, then you will get consistent results.
*/
Expand Down

0 comments on commit 662b8c9

Please sign in to comment.