Skip to content

Commit

Permalink
user uploads correct naming - #26
Browse files Browse the repository at this point in the history
  • Loading branch information
teo-sk committed Jul 27, 2012
1 parent f96855c commit b3cc622
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Model/VoteGroupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function create(PollInterface $poll)
public function save(VoteGroupInterface $voteGroup)
{
$this->doSave($voteGroup);

return $voteGroup;
}

/**
Expand Down
1 change: 1 addition & 0 deletions Model/VoteGroupManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function create(PollInterface $poll);
* Saves vote group to DB.
*
* @param VoteGroupInterface $voteGroup
* @return VoteGroupInterface
*/
public function save(VoteGroupInterface $voteGroup);

Expand Down
9 changes: 6 additions & 3 deletions Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,13 @@ public function create($id, Response &$response)
throw new \Exception(sprintf('"%s" is not a writable folder for uploads.', $this->uploadDir));
}

foreach ($data as $field) {
$voteGroup = $this->voteGroupManager->save($voteGroup);
$folder = $this->uploadDir . '/' . $voteGroup->getId();
mkdir($folder);

foreach ($data as $fieldName => $field) {
if ($field instanceof UploadedFile) {
//@TODO: create unique filename - votegroup id as folder
$field->move($this->uploadDir,'test');
$field->move($folder, $fieldName . '.' . $field->guessExtension());
}
}
}
Expand Down

0 comments on commit b3cc622

Please sign in to comment.