Skip to content

Commit b3cc622

Browse files
committed
user uploads correct naming - #26
1 parent f96855c commit b3cc622

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Model/VoteGroupManager.php

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function create(PollInterface $poll)
3636
public function save(VoteGroupInterface $voteGroup)
3737
{
3838
$this->doSave($voteGroup);
39+
40+
return $voteGroup;
3941
}
4042

4143
/**

Model/VoteGroupManagerInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function create(PollInterface $poll);
3131
* Saves vote group to DB.
3232
*
3333
* @param VoteGroupInterface $voteGroup
34+
* @return VoteGroupInterface
3435
*/
3536
public function save(VoteGroupInterface $voteGroup);
3637

Poll.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,13 @@ public function create($id, Response &$response)
256256
throw new \Exception(sprintf('"%s" is not a writable folder for uploads.', $this->uploadDir));
257257
}
258258

259-
foreach ($data as $field) {
259+
$voteGroup = $this->voteGroupManager->save($voteGroup);
260+
$folder = $this->uploadDir . '/' . $voteGroup->getId();
261+
mkdir($folder);
262+
263+
foreach ($data as $fieldName => $field) {
260264
if ($field instanceof UploadedFile) {
261-
//@TODO: create unique filename - votegroup id as folder
262-
$field->move($this->uploadDir,'test');
265+
$field->move($folder, $fieldName . '.' . $field->guessExtension());
263266
}
264267
}
265268
}

0 commit comments

Comments
 (0)