Skip to content

Commit

Permalink
fix filename when renaming through nameCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris Vaesen committed Feb 11, 2016
1 parent 90ddf4e commit 6e95014
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Model/Behavior/UploadBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function beforeSave(Event $event, Entity $entity, ArrayObject $options)
$data = $entity->get($field);
$path = $this->getPathProcessor($entity, $data, $field, $settings);
$basepath = $path->basepath();
$filename = $path->filename();
$data['name'] = $filename;
$files = $this->constructFiles($entity, $data, $field, $settings, $basepath);

$writer = $this->getWriter($entity, $data, $field, $settings);
Expand All @@ -86,7 +88,7 @@ public function beforeSave(Event $event, Entity $entity, ArrayObject $options)
return false;
}

$entity->set($field, $path->filename());
$entity->set($field, $filename);
$entity->set(Hash::get($settings, 'fields.dir', 'dir'), $basepath);
$entity->set(Hash::get($settings, 'fields.size', 'size'), $data['size']);
$entity->set(Hash::get($settings, 'fields.type', 'type'), $data['type']);
Expand Down

0 comments on commit 6e95014

Please sign in to comment.